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

Ci: Add Codeql and make trivy work for next containers #90

Merged
merged 16 commits into from
Dec 4, 2023

Conversation

tom-rm-meyer-ISST
Copy link
Contributor

@tom-rm-meyer-ISST tom-rm-meyer-ISST commented Nov 17, 2023

Description

As shown in issue sig-security#24, @scherersebastian showed how to setup the codeql scan and offered the review (comment).
I would love you to do the review!

Also as stated in configuring the trivy scans (#83) I updated the workflows to assign the latest tag to the current main branch to ensure trivy runs on non-release containers, too. Maybe you're also able to review that. If not it's fine.

Pre-review checks

Please ensure to do as many of the following checks as possible, before asking for committer review:

.github/workflows/codeql.yml Fixed Show fixed Hide fixed
.github/workflows/codeql.yml Fixed Show fixed Hide fixed
.github/workflows/codeql.yml Fixed Show fixed Hide fixed
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@tom-rm-meyer-ISST
Copy link
Contributor Author

also replaced versions of all workflows that reference a version (not main / master) to use the commit SHA. Thus, solves #86.

@tom-rm-meyer-ISST
Copy link
Contributor Author

Java Backend currently failing due to failure in tests (none given yet). Therefore we need to check to:

  • either replace autobuild by building with skipTests (will also speed up as soon as tests are given) OR
  • create tests

@scherersebastian
Copy link
Member

Java Backend currently failing due to failure in tests (none given yet). Therefore we need to check to:

* either replace autobuild by building with skipTests (will also speed up as soon as tests are given) OR

* create tests

@tom-rm-meyer-ISST the easiest way is to build it yourself, as reference you can see the IRS codeql workflow - they also use Java

@scherersebastian
Copy link
Member

trivy should scan the "latest" images, not "main". I created this as a short term solution, so you can see your findings. At this time no image with a latest tag was released.
I think there is even a TRG for having a "latest" tag.

@scherersebastian
Copy link
Member

Except of these minor changes, it looks good :)

@tom-rm-meyer-ISST
Copy link
Contributor Author

trivy should scan the "latest" images, not "main". I created this as a short term solution, so you can see your findings. At this time no image with a latest tag was released. I think there is even a TRG for having a "latest" tag.

I'm confused again:

I adjusted the Workflow to also assign the latest tag to images currently created for main (no release as no specific tag has been set). The TRG seems to only refer to the latest tag for versions in images:

  • latest is set, if I create a version 1.5.6 image
  • latest is not set, if I just merge to main without further tag

I used the example worfklow as basis and now added the latest tag also for the second case.

We could dicsuss in the office hour whats actually the intended behavior.

But for now: Trivy currently scans the main tag? Then in this PR, we could change it to latest.

@tom-rm-meyer-ISST
Copy link
Contributor Author

Java Backend currently failing due to failure in tests (none given yet). Therefore we need to check to:

* either replace autobuild by building with skipTests (will also speed up as soon as tests are given) OR

* create tests

@tom-rm-meyer-ISST the easiest way is to build it yourself, as reference you can see the IRS codeql workflow - they also use Java

Well, we have frontend and backend (javascript and java) that kind of adds some more steps. I'm meanwhile progressing with the testing so that we can merge this PR next week after I merged them :)

@scherersebastian
Copy link
Member

@tom-rm-meyer-ISST which PR? I can do the changes for you, but please link the PR you are talking of.

@tom-rm-meyer-ISST
Copy link
Contributor Author

@tom-rm-meyer-ISST which PR? I can do the changes for you, but please link the PR you are talking of.

Sorry @scherersebastian, I was talking about those two PR's (#91, #97) that added some tests. Those have been merged meanwhile.

After that I found out today, that the setup for the autobuild didn't work

  • I needed to bump the java version in the backend
  • I needed to setup java accordingly

The latter could be interesting for your recommended setups.

@scherersebastian could you please review this pr now? Everything seems to work now.

@tom-rm-meyer-ISST
Copy link
Contributor Author

@scherersebastian resolved comment. Please approve, if fine :)

Copy link
Member

@scherersebastian scherersebastian left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -61,14 +64,14 @@ jobs:
steps:
# Pull image from Docker Hub and run Trivy vulnerability scanner
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.14.0
uses: aquasecurity/trivy-action@2b6a709cf9c4025c5438138008beaddbb02086f0 # v0.14.0
with:
image-ref: "tractusx/app-puris-backend:main"
Copy link
Member

Choose a reason for hiding this comment

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

main to latest

# The branches below must be a subset of the branches above
branches: ["main"]
schedule:
- cron: "36 1 * * 0"
Copy link
Member

Choose a reason for hiding this comment

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

I would take this scan cycle 0 0 * * * , but this is up to you

Copy link
Member

Choose a reason for hiding this comment

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

it's once a day - it's free, why not :)

strategy:
fail-fast: false
matrix:
language: ["java", "javascript"]
Copy link
Member

Choose a reason for hiding this comment

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

Being honest, I am not one hundred percent sure, whether this will work.
javascript does not need autobuild.
I think the easiest solution is to test it out. Might be that you need to configure a separate set of steps just of javascript.
I would say, lets merge it, and see what happens - I will be there to help :)

@tom-rm-meyer-ISST tom-rm-meyer-ISST merged commit 11f40b4 into eclipse-tractusx:main Dec 4, 2023
12 checks passed
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.

2 participants