Skip to content

[SYCL][Devops] Fix DockerFile linting issues discovered by trivy #16290

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

Conversation

AlexeySachkov
Copy link
Contributor

@AlexeySachkov AlexeySachkov commented Dec 5, 2024

Linter/checker used: trivy v0.58.0

Issues addressed:

Issues remaining:

I didn't add HEALTHCHECK command to our containers, because I don't know if that makes sense and which command to launch. I.e. our containers they only provide some pre-installed tools, but they don't launch any services which we could check.

See https://avd.aquasec.com/misconfig/ds017

Docker best practices says that running `update` and `install` commands
separately may lead to situations where Docker skips `update` step and
re-uses cache leading to outdated versions of packages being installed.
See https://avd.aquasec.com/misconfig/ds002

Made it so that the last `USER` command in `base` and `build` is not
`root`.
See https://avd.aquasec.com/misconfig/ds002

Made it so our docker files have at least one `USER` command which is
not `root`.
@AlexeySachkov AlexeySachkov requested a review from a team as a code owner December 5, 2024 20:07
@AlexeySachkov
Copy link
Contributor Author

Note for reviewers: I have very little idea about how to validate this (though I see that some CI containers job have been launched), so any suggestions here are appreciated.

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

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

i think we have to wait until merge, nothing uses the PR containers i think, only the official ones

seems sane to me

@sarnex
Copy link
Contributor

sarnex commented Dec 5, 2024

CI failed in making the docker image, but for running them yeah I don't think we can do that here

@AlexeySachkov
Copy link
Contributor Author

CI failed in making the docker image, but for running them yeah I don't think we can do that here

Apparently some containers re-use other containers, that issue was fixed. Failure on AMD seems to be an infrastructure one (runner got disconnected). Moreover, we don't use images built as part of the PR in our pre-commit, so it shouldn't really be related.

@sarnex, @intel/dpcpp-devops-reviewers, @intel/llvm-gatekeepers, we need to agree on a strategy here. Considering that this change has a potential to disrupt all pre-commits, I suggest that we merge it ASAP and then monitor all pre-commits to quickly revert if we spot any issues.

@sarnex
Copy link
Contributor

sarnex commented Dec 9, 2024

@AlexeySachkov That's fine with me, can you watch the precommit CI or should I? If you, let me know when you're ready for merge.

@AlexeySachkov
Copy link
Contributor Author

@AlexeySachkov That's fine with me, can you watch the precommit CI or should I? If you, let me know when you're ready for merge.

I can watch it for a few more hours, let's hit merge

@AlexeySachkov AlexeySachkov merged commit ada8c86 into intel:sycl Dec 9, 2024
19 of 20 checks passed
@AlexeySachkov AlexeySachkov deleted the private/asachkov/apply-docker-best-practices branch December 9, 2024 15:38
@sarnex
Copy link
Contributor

sarnex commented Dec 9, 2024

cool, if something crazy happens feel free to ping me

@AlexeySachkov
Copy link
Contributor Author

https://github.com/intel/llvm/actions/runs/12239030332 - post-commit job to re-build containers has finished successfully. If I understand correctly, starting from this point all new pre-commits should use new containers.

@sarnex
Copy link
Contributor

sarnex commented Dec 9, 2024

yeah i think we need to wait for a new precommit/postcommit run. you can run them manually in a fake pr if you want or just wait and check

@sarnex
Copy link
Contributor

sarnex commented Dec 10, 2024

@AlexeySachkov Looks like the nightly failed, can you take a look?

https://github.com/intel/llvm/actions/runs/12248716063/job/34169121051#step:4:194

@AlexeySachkov
Copy link
Contributor Author

@AlexeySachkov Looks like the nightly failed, can you take a look?

https://github.com/intel/llvm/actions/runs/12248716063/job/34169121051#step:4:194

Thanks for letting me know, @sarnex, we seem to have one more case of one docker image re-using another which is not covered by pre-commit. I will address

AlexeySachkov added a commit to AlexeySachkov/llvm that referenced this pull request Dec 10, 2024
We already have `sycl` user created by a base image, no need to repeat
that.
This is a follow-up to intel#16290 to address an issue which was
not caught by pre-commit.
@AlexeySachkov
Copy link
Contributor Author

@AlexeySachkov Looks like the nightly failed, can you take a look?

https://github.com/intel/llvm/actions/runs/12248716063/job/34169121051#step:4:194

#16324 should hopefully fix that

sarnex added a commit that referenced this pull request Dec 12, 2024
…trivy" (#16346)

Reverts #16290

Discussed with Alexey offline, reverting for now until we can address
some more issues.

CI failures expected, it's not actually using the changes in this PR.
sarnex pushed a commit that referenced this pull request Dec 19, 2024
…16411)

This is a re-submit of #16290 with fixes from #16324 and some more extra
changes.

Issues addressed:
- AVD-DS-0017 (HIGH): The instruction 'RUN <package-manager> update'
should always be followed by '<package-manager> install' in the same RUN
statement.
  See https://avd.aquasec.com/misconfig/ds017
- AVD-DS-0002 (HIGH): Specify at least 1 USER command in Dockerfile with
non-root user as argument
  See https://avd.aquasec.com/misconfig/ds002
- AVD-DS-0002 (HIGH): Last USER command in Dockerfile should not be
'root'

Issues remaining:
- AVD-DS-0026 (LOW): Add HEALTHCHECK instruction in your Dockerfile
  See https://avd.aquasec.com/misconfig/ds026

I didn't add `HEALTHCHECK` command to our containers, because I don't
know if that makes sense and which command to launch. I.e. our
containers they only provide some pre-installed tools, but they don't
launch any services which we could check.

User creation was outlined into a separate helper script. Our containers
only come with `sycl_ci` user now which requires a password to use
`sudo`. However, it is still possible to get the original `sycl` user
for those who uses that container locally and needs `sudo` access.
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