Skip to content

Updates to generated filenames - #4043

Merged
Amndeep7 merged 26 commits into
mainfrom
xccdf_tag_verification
Jun 15, 2025
Merged

Amndeep7 merged 26 commits into
mainfrom
xccdf_tag_verification

Conversation

@georgedias

Copy link
Copy Markdown
Contributor

Fixed potential path traversal issues

@georgedias
georgedias requested a review from Amndeep7 June 9, 2025 22:42
georgedias and others added 16 commits June 10, 2025 08:41
Signed-off-by: George M Dias <[email protected]>
…th traversal concerns.

1) Removed the basedir check in inspec_profile as unnecessary on top of
   the checks that we are already doing.
2) Added checks (in some cases might be an overabundance of caution) for
   any filenames that were not directly supplied by the user or us the
   code authors.
3) Reworked convertfullnametopath function and renamed it to basenane
   and then used it everywhere instead of path.basenane which as
   explained in the comment is flawed in some of the ways/places we use
   this function.  The rename is cause that's the actual behavior that
   was being done.
4) Slightly extended the checkSuffix function and use it in some more
   places.  Additionally ensure that the checkSuffix call happens on the
   outside of any of the basename calls.
4) Linting

Signed-off-by: Amndeep Singh Mann <[email protected]>
Signed-off-by: Amndeep Singh Mann <[email protected]>
Signed-off-by: George M Dias <[email protected]>
Comment thread src/utils/global.ts Resolved
Comment thread .github/workflows/build-rpm.yml Resolved
Comment thread .github/workflows/build-rpm.yml Resolved

@georgedias georgedias left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine with me

Comment thread src/utils/global.ts Resolved
Comment thread src/utils/global.ts Outdated
trimmedPath.lastIndexOf('/'),
trimmedPath.lastIndexOf('\\'),
)
return trimmedPath.slice(Math.max(0, lastSeparatorIndex + 1))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the Math.max here as the slice() method already handles out-of-range indices gracefully (e.g., slicing from 0 if lastSeparatorIndex is -1).

Suggest changing to this:
// Return the substring after the last separator, or the entire string if no separator is found
return trimmedPath.slice(lastSeparatorIndex + 1);

Comment thread .github/workflows/build-rpm.yml Resolved
Comment thread .github/workflows/build-rpm.yml Resolved

@georgedias georgedias left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR should now be ready.

Amndeep7 added 2 commits June 15, 2025 15:54
Signed-off-by: Amndeep Singh Mann <[email protected]>
…curacy when directly provided the empty string or a string consisting of separators that would eventually be processed into the empty string

Signed-off-by: Amndeep Singh Mann <[email protected]>
@Amndeep7
Amndeep7 dismissed their stale review June 15, 2025 19:59

Satisfied

@Amndeep7 Amndeep7 changed the title Updates to inspec_profile Process Updates to generated filenames Jun 15, 2025
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
10.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@Amndeep7
Amndeep7 merged commit 6d636d8 into main Jun 15, 2025
@mergify
mergify Bot deleted the xccdf_tag_verification branch June 15, 2025 20:23
@Amndeep7 Amndeep7 linked an issue Jun 20, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request for Security Contact Email for Vulnerability Disclosure

2 participants