You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Includes product update to be announced in the next stable release notes
What does this PR do?
This PR adds acceptance tests to validate the SARIF and human-readable outputs of the secrets test command. These tests are designed to codify our rendering expectations and serve as a shared contract for the CLI team to iterate against.
Several execSync calls interpolate path variables (like TEMP_LOCAL_PATH and NO_GIT_DIR) directly into shell commands without quoting. This will cause tests to fail if the environment's workspace or temporary directory path contains spaces. Additionally, using shell commands like rm -rf, mkdir -p, and cp -r via execSync is non-portable across operating systems (e.g., Windows). Since the project already depends on rimraf and target Node 20, consider using built-in methods like fs.rmSync(path, { recursive: true, force: true }) or fs.mkdirSync(path, { recursive: true }) for better reliability.
execSync(`mkdir -p ${NO_GIT_DIR}`);execSync(`cp -r ${TEMP_LOCAL_PATH}/${TEST_DIR}/* ${NO_GIT_DIR}/`,{stdio: 'pipe'});const{ code, stdout, stderr }=awaitrunSnykCLI(`secrets test ${NO_GIT_DIR}`,{ env },);expect(stderr).toBe('');expect(code).toBe(EXIT_CODES.VULNS_FOUND);// Finding ID should not be included when it starts with UNDEFINEDexpect(stdout).not.toContain('Finding ID: UNDEFINED');}finally{try{execSync(`rm -rf ${NO_GIT_DIR}`,{stdio: 'pipe'});
The runSnykCLI helper is called with unquoted path arguments in multiple test cases. If the execution path contains spaces, the CLI will misinterpret the single path as multiple separate arguments, leading to test failures. This is inconsistent with the correct quoting used for testDir in line 352.
`secrets test ${TEMP_LOCAL_PATH}/${TEST_DIR}`,{ env },
The test intended to verify that Finding IDs are omitted when they cannot be calculated (line 256) uses a weak assertion. expect(stdout).not.toContain('Finding ID: UNDEFINED') only proves that the specific "UNDEFINED" string is absent; it doesn't verify that the entire Finding ID: field is omitted from the output as described in the test's purpose. If the output mistakenly included a blank Finding ID: or an incorrect value, the test would still pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Submission Checklist
are release-note ready, emphasizing
what was changed, not how.
What does this PR do?
This PR adds acceptance tests to validate the SARIF and human-readable outputs of the
secrets testcommand. These tests are designed to codify our rendering expectations and serve as a shared contract for the CLI team to iterate against.Where should the reviewer start?
test/jest/acceptance/snyk-secrets/snyk-secrets-test-user-journey.spec.ts;How should this be manually tested?
Run the acceptance tests locally.
What's the product update that needs to be communicated to CLI users?
N/A
Risk assessment (Low | Medium | High)?
Low - extends test suite.
What are the relevant tickets?