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

Add Violations support for JAS scanners #241

Merged
merged 138 commits into from
Dec 31, 2024

Conversation

eranturgeman
Copy link
Contributor

@eranturgeman eranturgeman commented Nov 19, 2024

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • Updated the Contributing page / ReadMe page / CI Workflow files if needed.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

Depends on:

Add Support for JAS violations

1. Allow generating JAS violations in the scan by providing watch, GitRepositoryKey, or project attributes.

  • New violation resource GitRepositoryKey: the http/https git clone url of the repository the code related to. (The actual expected value is converted by removing the protocol)
  • Passing the violation context (new and old) variables to Xray (SCA scan) and to the analyzerManager (JAS scans)

2. Generating violations in all output formats (adding attributes to tables/structs where needed)

3. Violations should also be generated for binary scans that support JAS (passing the project key to the analyzerManager)

4. In Frogbot,GitRepositoryKey is always passed to the command, this means the user will start to see only violations and not vulnerabilities as the default behavior without supplying any arguments, to avoid breaking:

  • If audit command is supplied with GitRepositoryKey we will fetch the active watches on this resource, if non exists we will show vulnerabilities (only if the user did not request any other params like watches \ project key \ repo path...)

Additional changes

  • Adds a resultsContext struct to replace commonGraphScanParams to hold and handle all the attributes that can be used to generate results (watches, project key, git repo ....)
  • Fix Typos found in the repository
  • Adds an annotation for each sub-scan about its status: ScanResult[T interface{}].StatusCode (not performed = nil, completed = 0, failed != 0)
  • Improve validations, adding an option to test more specific counts, simplify tests in convertor_test.go
  • Bug Fix - display violations in binary scans (jf scan / jf docker scan) when --repo-path is present
  • Add project key tests when passing: JFROG_SECURITY_CLI_TESTS_JFROG_PLATFORM_PROJECT_KEY
  • Update AnalyzerManager version to 1.13.2

…dded the new parsed violations results to ApplicabilityScanManager.
…ew parsed violations results to IacScanManager.
…new parsed violations results to SastScanManager.
…e new parsed violations results to SecretScanManager.
@eranturgeman eranturgeman marked this pull request as draft November 19, 2024 10:48
@eranturgeman eranturgeman added the new feature Automatically generated release notes label Nov 19, 2024
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Dec 26, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 26, 2024
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Dec 29, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 29, 2024
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Dec 29, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 29, 2024
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Dec 29, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 29, 2024
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Dec 31, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 31, 2024
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Dec 31, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Dec 31, 2024
Copy link

👍 Frogbot scanned this pull request and did not find any new security issues.


Copy link

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/jfrog/jfrog-cli-security 0.00% (ø)
github.com/jfrog/jfrog-cli-security/cli 0.00% (ø)
github.com/jfrog/jfrog-cli-security/commands/audit 0.00% (ø)
github.com/jfrog/jfrog-cli-security/commands/audit/sca 0.00% (ø)
github.com/jfrog/jfrog-cli-security/commands/enrich 0.00% (ø)
github.com/jfrog/jfrog-cli-security/commands/scan 0.00% (ø)
github.com/jfrog/jfrog-cli-security/jas 0.00% (ø)
github.com/jfrog/jfrog-cli-security/jas/applicability 0.00% (ø)
github.com/jfrog/jfrog-cli-security/jas/iac 0.00% (ø)
github.com/jfrog/jfrog-cli-security/jas/runner 0.00% (ø)
github.com/jfrog/jfrog-cli-security/jas/sast 0.00% (ø)
github.com/jfrog/jfrog-cli-security/jas/secrets 0.00% (ø)
github.com/jfrog/jfrog-cli-security/tests 0.00% (ø)
github.com/jfrog/jfrog-cli-security/tests/utils 0.00% (ø)
github.com/jfrog/jfrog-cli-security/tests/utils/integration 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/formats 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/formats/sarifutils 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/results 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/results/conversion 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/results/conversion/sarifparser 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/results/conversion/simplejsonparser 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/results/conversion/summaryparser 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/results/conversion/tableparser 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/results/output 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/techutils 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/validations 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/xray/scangraph 0.00% (ø)
github.com/jfrog/jfrog-cli-security/utils/xsc 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/jfrog/jfrog-cli-security/cli/scancommands.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/audit/audit.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/audit/auditparams.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/audit/sca/common.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/audit/scarunner.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/enrich/enrich.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/scan/buildscan.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/scan/dockerscan.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/commands/scan/scan.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/jas/analyzermanager.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/jas/applicability/applicabilitymanager.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/jas/common.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/jas/iac/iacscanner.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/jas/runner/jasrunner.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/jas/sast/sastscanner.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/jas/secrets/secretsscanner.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/tests/config.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/tests/consts.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/tests/utils/integration/test_integrationutils.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/tests/utils/test_utils.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/auditbasicparams.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/formats/conversion.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/formats/sarifutils/sarifutils.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/formats/sarifutils/test_sarifutils.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/formats/simplejsonapi.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/formats/table.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/common.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/conversion/convertor.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/conversion/sarifparser/sarifparser.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/conversion/simplejsonparser/simplejsonparser.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/conversion/summaryparser/summaryparser.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/conversion/tableparser/tableparser.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/output/resultwriter.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/results/results.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/techutils/techutils.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/utils.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/validations/test_mocks.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/validations/test_validate_sarif.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/validations/test_validate_sca.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/validations/test_validate_simple_json.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/validations/test_validate_summary.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/validations/test_validation.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/xray/scangraph/params.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/xray/scangraph/scangraph.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/xsc/analyticsmetrics.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/xsc/configprofile.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/xsc/errorreport.go 0.00% (ø) 0 0 0
github.com/jfrog/jfrog-cli-security/utils/xsc/xscmanager.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/jfrog/jfrog-cli-security/audit_test.go
  • github.com/jfrog/jfrog-cli-security/commands/audit/audit_test.go
  • github.com/jfrog/jfrog-cli-security/jas/applicability/applicabilitymanager_test.go
  • github.com/jfrog/jfrog-cli-security/jas/common_test.go
  • github.com/jfrog/jfrog-cli-security/jas/iac/iacscanner_test.go
  • github.com/jfrog/jfrog-cli-security/jas/runner/jasrunner_test.go
  • github.com/jfrog/jfrog-cli-security/jas/sast/sastscanner_test.go
  • github.com/jfrog/jfrog-cli-security/jas/secrets/secretsscanner_test.go
  • github.com/jfrog/jfrog-cli-security/scans_test.go
  • github.com/jfrog/jfrog-cli-security/utils/results/conversion/convertor_test.go
  • github.com/jfrog/jfrog-cli-security/utils/results/conversion/sarifparser/sarifparser_test.go
  • github.com/jfrog/jfrog-cli-security/utils/results/conversion/simplejsonparser/simplejsonparser_test.go
  • github.com/jfrog/jfrog-cli-security/utils/xsc/analyticsmetrics_test.go
  • github.com/jfrog/jfrog-cli-security/xsc_test.go

@attiasas attiasas merged commit fd5e5f3 into jfrog:dev Dec 31, 2024
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Automatically generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants