Skip to content

fix: acceptance tests for secrets test output [PS-357]#6628

Open
alexandru-manea-snyk wants to merge 1 commit intomainfrom
fix/PS-357/extension-secrets-output-acceptance-tests
Open

fix: acceptance tests for secrets test output [PS-357]#6628
alexandru-manea-snyk wants to merge 1 commit intomainfrom
fix/PS-357/extension-secrets-output-acceptance-tests

Conversation

@alexandru-manea-snyk
Copy link
Copy Markdown
Contributor

@alexandru-manea-snyk alexandru-manea-snyk commented Mar 9, 2026

Pull Request Submission Checklist

  • Follows CONTRIBUTING guidelines
  • Commit messages
    are release-note ready, emphasizing
    what was changed, not how.
  • Includes detailed description of changes
  • Contains risk assessment (Low | Medium | High)
  • Highlights breaking API changes (if applicable)
  • Links to automated tests covering new functionality
  • Includes manual testing instructions (if necessary)
  • Updates relevant GitBook documentation (PR link: ___)
  • 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.

Where should the reviewer start?

  • test/jest/acceptance/snyk-secrets/snyk-secrets-test-user-journey.spec.ts;
  • the document linked in the ticket;

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?

@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Mar 9, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch 6 times, most recently from 97767d5 to b04f5e4 Compare March 13, 2026 13:25
@alexandru-manea-snyk alexandru-manea-snyk marked this pull request as ready for review March 13, 2026 13:25
@alexandru-manea-snyk alexandru-manea-snyk requested review from a team as code owners March 13, 2026 13:25
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from b04f5e4 to 624110a Compare March 13, 2026 14:42
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 624110a to 1352c55 Compare March 13, 2026 15:02
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 1352c55 to 7f2d38b Compare March 18, 2026 08:48
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 7f2d38b to cc9753d Compare March 18, 2026 12:37
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from cc9753d to 74f0b68 Compare March 18, 2026 15:34
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 74f0b68 to cd18a7a Compare March 18, 2026 15:42
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from cd18a7a to d89c8ea Compare March 30, 2026 08:47
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from d89c8ea to 6eedd64 Compare March 30, 2026 08:57
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 7a9c153 to 7ee603b Compare March 30, 2026 15:36
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 7ee603b to 3006e78 Compare March 31, 2026 06:25
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 3006e78 to b7a5773 Compare March 31, 2026 08:11
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from b7a5773 to d8b4067 Compare March 31, 2026 08:44
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from d8b4067 to a3af591 Compare March 31, 2026 09:11
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch 2 times, most recently from c0e64c0 to 9b4bef8 Compare March 31, 2026 15:35
@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Unsafe run access 🟠 [major]

In setupIsolatedIgnoreEnv, the code parses the CLI output and immediately accesses jsonOutput.runs[0].results. This is dangerous because if the CLI fails to produce any runs (e.g., due to an execution error or an empty scan), jsonOutput.runs could be an empty array or undefined. Accessing the first element of an empty array will result in undefined, and subsequent access to .results will throw a TypeError, crashing the test runner before any assertions can provide useful feedback.

const jsonOutput = JSON.parse(jsonStdout);
const results = jsonOutput.runs[0].results || [];
Property name mismatch 🟠 [major]

There is a discrepancy in how finding IDs are extracted in setupIsolatedIgnoreEnv compared to how they are validated in later tests. The setup logic extracts IDs from r.fingerprints?.identity, but the validation logic in the SARIF tests explicitly checks for a property named fingerprint. If the CLI output only provides fingerprint, the extraction at line 129 will return an empty array, no ignores will be applied during setup, and the test for rendering ignores will fail to see the expected suppressed results.

results.map((r: any) => r.fingerprints?.identity).filter(Boolean),
📚 Repository Context Analyzed

This review considered 6 relevant code sections from 4 files (average relevance: 1.00)

@snyk-pr-review-bot

This comment has been minimized.


describe('validation', () => {
it('should return an error for --report', async () => {
it.skip('should return an error for --report', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: same here

let's add a comment on these skipped tests stating why they're skipped, otherwise we should remove these tests instead of skipping them

Copy link
Copy Markdown
Contributor

@j-luong j-luong left a comment

Choose a reason for hiding this comment

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

pre-approved to unblock once the issues are resolved

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 9b4bef8 to b1dc77c Compare April 6, 2026 06:55
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from b1dc77c to 2da636f Compare April 6, 2026 07:08
@snyk-pr-review-bot

This comment has been minimized.

@alexandru-manea-snyk alexandru-manea-snyk force-pushed the fix/PS-357/extension-secrets-output-acceptance-tests branch from 2da636f to f3bdbe4 Compare April 7, 2026 14:40
@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incomplete Directory Copy 🟡 [minor]

The copyFolderSync helper function only checks isFile(). It does not handle symbolic links or other special file types. If the source directory contains symlinks (common in some repositories), copyFileSync may either fail or copy the file content instead of the link, which could lead to inconsistent test results compared to the original repository structure.

  if (statSync(fromPath).isFile()) copyFileSync(fromPath, toPath);
  else copyFolderSync(fromPath, toPath);
});
Shell Injection Risk 🟡 [minor]

In beforeAll, execSync is called with a template string containing TEMP_LOCAL_PATH. While TEMP_LOCAL_PATH comes from makeTmpDirectory(), which is generally safe, it is better practice to pass arguments as an array to execFileSync or ensure paths are properly quoted/escaped to prevent issues with spaces or special characters in the temporary path.

execSync(
  `git clone ${TEST_REPO_URL} ${TEMP_LOCAL_PATH} && cd ${TEMP_LOCAL_PATH} && git checkout ${TEST_REPO_COMMIT}`,
📚 Repository Context Analyzed

This review considered 7 relevant code sections from 6 files (average relevance: 1.00)

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.

3 participants