Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add SCM report test support [ZEN-668] #4745

Merged
merged 10 commits into from
Jul 19, 2023

Conversation

novalex
Copy link
Contributor

@novalex novalex commented Jul 14, 2023

What does this PR do?

Implements support for running Code tests against existing SCM projects and uploading/reporting results under them.
AKA CLI Uploads Phase 2, AKA CLI-triggered SCM Tests.

Follows the existing --report flow logic, with some distinctions:

  • It is triggered by providing --project-id and --commit-id instead of --project-name as used by the files flow. That is because the files flow can create or fetch a CLI project, whereas this one relies on an SCM Code project existing.
  • It calls analyzeScmProject from code-client, instead of analyzeFolders. That is because it triggers an SCM analysis in our backend, and does not need to upload local files first like the file-based flow.

Otherwise the interfaces and handling logic are very similar.

Where should the reviewer start?

How should this be manually tested?

export SNYK_CODE_CLIENT_PROXY_URL=https://deeproxy.dev.snyk.io
export SNYK_API=https://dev.snyk.io/api
export SNYK_TOKEN=<SNYK_API_KEY>
cd <TEST_PROJECT_PATH>
<CLI_PATH>/bin/snyk code test --report --project-id=<SNYK_PROJECT_ID> --commit-id=$(git rev-parse HEAD)

Make sure --commit-id is a valid commit available on the remote SCM your Snyk project is linked to.

Any background context you want to provide?

What are the relevant tickets?

https://snyksec.atlassian.net/browse/ZEN-668

Screenshots

Additional questions

@novalex novalex marked this pull request as ready for review July 14, 2023 20:22
@novalex novalex requested review from a team as code owners July 14, 2023 20:22
@novalex novalex force-pushed the feat/ZEN-668/add-scm-report-test-support branch from 8069136 to 1fbe158 Compare July 17, 2023 08:02
Copy link
Contributor

@patricia-v patricia-v left a comment

Choose a reason for hiding this comment

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

LGTM 🙌

Once again, I'll leave the final approval to @michelkaporin 😁

src/lib/plugins/sast/analysis.ts Show resolved Hide resolved
src/lib/plugins/sast/analysis.ts Outdated Show resolved Hide resolved
src/lib/plugins/sast/types.ts Show resolved Hide resolved
test/jest/unit/snyk-code/snyk-code-test-report.spec.ts Outdated Show resolved Hide resolved
@novalex novalex force-pushed the feat/ZEN-668/add-scm-report-test-support branch 2 times, most recently from 4b1443d to 069d48d Compare July 18, 2023 15:19
Copy link
Contributor

@michelkaporin michelkaporin left a comment

Choose a reason for hiding this comment

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

Leaving the codebase in a better state, great work! :)

@novalex novalex force-pushed the feat/ZEN-668/add-scm-report-test-support branch from 069d48d to a5274d8 Compare July 19, 2023 08:29
@novalex novalex enabled auto-merge (squash) July 19, 2023 08:35
@novalex novalex merged commit 668e99c into master Jul 19, 2023
11 checks passed
@novalex novalex deleted the feat/ZEN-668/add-scm-report-test-support branch July 19, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants