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 a new workflow to check vulnerabilities using trivy #9044

Merged
merged 3 commits into from
Jul 18, 2022

Conversation

gortiz
Copy link
Contributor

@gortiz gortiz commented Jul 12, 2022

This PR adds a new workflow that executes Trivy in order to look for vulnerabilities. Every PR will trigger that workflow and it will add a new check that will include all known vulnerabilities added in the PR.

Some vulnerabilities may do not have a fix yet or it may not be possible to update to the version that fixes the vulnerability (for example, due to some breaking change). In that case we add the vulnerabilities that have to be skipped in a new file called .trivyignore. For example, see the Conjur repo.

Trivy is an open source program with a huge vulnerability db that analyzes artifacts looking for vulnerabilities. Although Trivy can be used in different ways, the most common way to use it is to analyze a docker image. By doing that it can analyze the code dependencies (for example, jars) but also SO dependencies (like the zlib version that is used). Trivy can also be used to analyze infrastructure as code and other configs, but I don't have experience doing so.

@gortiz gortiz force-pushed the add_vuln_check branch 13 times, most recently from 1fda43b to a865eed Compare July 12, 2022 15:59
@gortiz gortiz changed the title Add a new workflow to check vulnerabilities using trivy [DRAFT] Add a new workflow to check vulnerabilities using trivy Jul 12, 2022
@gortiz gortiz force-pushed the add_vuln_check branch 4 times, most recently from 63c19ee to 684a681 Compare July 13, 2022 08:47
@codecov-commenter
Copy link

codecov-commenter commented Jul 13, 2022

Codecov Report

Merging #9044 (2e034cf) into master (a2cde56) will increase coverage by 1.14%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master    #9044      +/-   ##
============================================
+ Coverage     68.96%   70.11%   +1.14%     
- Complexity     4727     4743      +16     
============================================
  Files          1831     1831              
  Lines         96368    96382      +14     
  Branches      14411    14408       -3     
============================================
+ Hits          66462    67576    +1114     
+ Misses        25271    24141    -1130     
- Partials       4635     4665      +30     
Flag Coverage Δ
integration1 26.59% <ø> (-0.05%) ⬇️
integration2 24.82% <ø> (?)
unittests1 66.85% <ø> (+0.01%) ⬆️
unittests2 15.41% <ø> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ller/helix/core/minion/TaskTypeMetricsUpdater.java 80.00% <0.00%> (-20.00%) ⬇️
...mmon/request/context/predicate/NotEqPredicate.java 76.92% <0.00%> (-7.70%) ⬇️
...roller/helix/core/relocation/SegmentRelocator.java 72.97% <0.00%> (-5.41%) ⬇️
...not/broker/broker/helix/ClusterChangeMediator.java 75.26% <0.00%> (-5.38%) ⬇️
.../helix/core/minion/MinionInstancesCleanupTask.java 77.27% <0.00%> (-4.55%) ⬇️
...lix/core/realtime/PinotRealtimeSegmentManager.java 79.58% <0.00%> (-4.19%) ⬇️
...pache/pinot/core/query/optimizer/filter/Range.java 87.75% <0.00%> (-4.09%) ⬇️
...r/validation/RealtimeSegmentValidationManager.java 76.05% <0.00%> (-2.82%) ⬇️
...nction/DistinctCountBitmapAggregationFunction.java 52.84% <0.00%> (-2.08%) ⬇️
...controller/helix/core/minion/PinotTaskManager.java 67.29% <0.00%> (-1.58%) ⬇️
... and 127 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2cde56...2e034cf. Read the comment docs.

@gortiz gortiz force-pushed the add_vuln_check branch 11 times, most recently from 4f64534 to 78c8da9 Compare July 14, 2022 12:49
Comment on lines 28 to 33
paths-ignore:
- "contrib/**"
- "docs/**"
- "licenses/**"
- "licenses-binary/**"
- "**.md"
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of ignore path, let's explicitly run this when **/pom.xml is changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a very good idea. We also have to add some extra files like the package.json files or dockerfiles, but it totally makes sense

.github/workflows/pinot_vuln_check.yml Outdated Show resolved Hide resolved
Comment on lines +46 to +50
for tag in "${tags[@]}"
do
echo "Plan to build docker images for: ${DOCKER_IMAGE_NAME}:${tag}"
DOCKER_BUILD_TAGS+=" --tag ${DOCKER_IMAGE_NAME}:${tag} "
done
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason we have to add multiple docker build tags?

Copy link
Contributor Author

@gortiz gortiz Jul 15, 2022

Choose a reason for hiding this comment

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

This has been copied from .pinot_docker_image_build_and_push.sh. In the workflow I always use a single tag (the commit sha)

vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
Copy link
Contributor

Choose a reason for hiding this comment

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

is there an option to not create a failed GHA task but instead comment on the PR like the codecov bot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find it. But the task compares the vulns in source and target branch. If no new vulnerability is added, it should be empty even if we have vulns in master. At least that is what I infer from the code scanning result.

I would recommend to merge the PR as it is to make it clear there are some vulnerabilities. We can add to .trivyignore the once we don't plan to fix soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

i see. so if I understand correctly:

  • the reason why this PR has so many vulns is b/c current master doesn't have a baseline vulnerability SARIF result.
  • once merged, the first commit on master will have a large SARIF but the next one should be empty if it didn't modify any dependencies. correct?

@walterddr walterddr mentioned this pull request Jul 15, 2022
@gortiz gortiz changed the title [DRAFT] Add a new workflow to check vulnerabilities using trivy Add a new workflow to check vulnerabilities using trivy Jul 18, 2022
@gortiz
Copy link
Contributor Author

gortiz commented Jul 18, 2022

I think this is ready to merge

Copy link
Contributor

@xiangfu0 xiangfu0 left a comment

Choose a reason for hiding this comment

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

lgtm, shall we merge it now or until we fix all the vulnerability issues then merge?

@xiangfu0 xiangfu0 merged commit c006f59 into apache:master Jul 18, 2022
yuanbenson pushed a commit to yuanbenson/pinot that referenced this pull request Jul 20, 2022
* Add a new workflow to check vulnerabilities using trivy

* Add EOF new line

* Run Pinot dependencies check only when dependency related files change
@gortiz gortiz deleted the add_vuln_check branch September 21, 2022 07:02
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.

4 participants