Run Docker container as current user
Fixes #1975.
Previously, mega-linter-runner ran the MegaLinter Docker image as root. Users whose files became owned by root as a consequence of this behavior will need to chown them to be owned by the appropriate user. This change only affects POSIX platforms, because process.getuid and process.getgid are only available there.
Proposed Changes
- Instruct the MegaLinter Docker container to inherit the UID and GID of the mega-linter-runner process.
Readiness Checklist
Author/Contributor
- [x] Add entry to the CHANGELOG listing the change and linking to the corresponding issue (if appropriate)
- [x] If documentation is needed for this change, has that been included in this pull request
Reviewing Maintainer
- [x] Label as
breakingif this is a large fundamental change - [x] Label as either
automation,bug,documentation,enhancement,infrastructure, orperformance
π¦ MegaLinter status: β οΈ WARNING
| Descriptor | Linter | Files | Fixed | Errors | Elapsed time |
|---|---|---|---|---|---|
| β BASH | bash-exec | 6 | 0 | 0.01s | |
| β BASH | shellcheck | 6 | 0 | 0.15s | |
| β BASH | shfmt | 6 | 0 | 0 | 0.3s |
| β COPYPASTE | jscpd | yes | no | 2.48s | |
| β DOCKERFILE | hadolint | 116 | 0 | 14.84s | |
| β JSON | eslint-plugin-jsonc | 21 | 0 | 0 | 2.09s |
| β JSON | jsonlint | 19 | 0 | 0.18s | |
| β JSON | v8r | 21 | 0 | 13.23s | |
| β οΈ MARKDOWN | markdownlint | 312 | 0 | 230 | 6.56s |
| β MARKDOWN | markdown-link-check | 312 | 0 | 5.39s | |
| β MARKDOWN | markdown-table-formatter | 312 | 0 | 0 | 16.16s |
| β OPENAPI | spectral | 1 | 0 | 1.43s | |
| β οΈ PYTHON | bandit | 185 | 54 | 2.02s | |
| β PYTHON | black | 185 | 0 | 0 | 4.75s |
| β PYTHON | flake8 | 185 | 0 | 2.92s | |
| β PYTHON | isort | 185 | 0 | 0 | 0.66s |
| β PYTHON | mypy | 185 | 0 | 6.59s | |
| β PYTHON | pylint | 185 | 0 | 10.69s | |
| β οΈ PYTHON | pyright | 185 | 251 | 15.72s | |
| β PYTHON | ruff | 185 | 0 | 0 | 0.36s |
| β REPOSITORY | checkov | yes | no | 29.94s | |
| β REPOSITORY | git_diff | yes | no | 0.3s | |
| β REPOSITORY | secretlint | yes | no | 11.95s | |
| β REPOSITORY | trivy | yes | no | 27.5s | |
| β SPELL | cspell | 753 | 0 | 19.3s | |
| β SPELL | misspell | 572 | 0 | 0 | 0.69s |
| β XML | xmllint | 3 | 0 | 0 | 0.32s |
| β YAML | prettier | 81 | 0 | 0 | 2.79s |
| β YAML | v8r | 23 | 0 | 60.19s | |
| β YAML | yamllint | 82 | 0 | 1.09s |
See detailed report in MegaLinter reports
.... but CI seems to disagree ^^
What sources of persistence between jobs are there (e.g., caching, artifacts, the Docker images themselves)? My instinct is that some files may still be owned by root that should never have been because of the bug this change seeks to fix.
Codecov Report
Merging #1985 (f5ea7e2) into main (fb2fe2e) will increase coverage by
0.02%. The diff coverage isn/a.
:mega: This organization is not using Codecovβs GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
@@ Coverage Diff @@
## main #1985 +/- ##
==========================================
+ Coverage 83.00% 83.03% +0.02%
==========================================
Files 171 171
Lines 4514 4514
==========================================
+ Hits 3747 3748 +1
+ Misses 767 766 -1
| Impacted Files | Coverage Ξ | |
|---|---|---|
| megalinter/reporters/AzureCommentReporter.py | 42.10% <ΓΈ> (ΓΈ) |
|
| megalinter/reporters/UpdatedSourcesReporter.py | 89.74% <0.00%> (+2.56%) |
:arrow_up: |
:mega: Weβre building smart automated test selection to slash your CI/CD build times. Learn more
π¦ MegaLinter status: β οΈ WARNING
| Descriptor | Linter | Files | Fixed | Errors | Elapsed time |
|---|---|---|---|---|---|
| β BASH | bash-exec | 6 | 0 | 0.01s | |
| β BASH | shellcheck | 6 | 0 | 0.14s | |
| β BASH | shfmt | 6 | 0 | 0 | 0.04s |
| β COPYPASTE | jscpd | yes | no | 2.65s | |
| β DOCKERFILE | hadolint | 116 | 0 | 16.7s | |
| β JSON | eslint-plugin-jsonc | 21 | 0 | 0 | 1.8s |
| β JSON | jsonlint | 19 | 0 | 0.18s | |
| β JSON | npm-package-json-lint | yes | no | 0.64s | |
| β JSON | v8r | 21 | 0 | 13.94s | |
| β οΈ MARKDOWN | markdownlint | 312 | 2 | 230 | 6.22s |
| β MARKDOWN | markdown-link-check | 312 | 0 | 5.23s | |
| β MARKDOWN | markdown-table-formatter | 312 | 2 | 0 | 16.68s |
| β OPENAPI | spectral | 1 | 0 | 1.48s | |
| β οΈ PYTHON | bandit | 185 | 54 | 2.18s | |
| β PYTHON | black | 185 | 0 | 0 | 4.06s |
| β PYTHON | flake8 | 185 | 0 | 1.96s | |
| β PYTHON | isort | 185 | 0 | 0 | 0.45s |
| β PYTHON | mypy | 185 | 0 | 7.36s | |
| β PYTHON | pylint | 185 | 0 | 11.39s | |
| β οΈ PYTHON | pyright | 185 | 251 | 16.34s | |
| β PYTHON | ruff | 185 | 0 | 0 | 0.15s |
| β REPOSITORY | checkov | yes | no | 32.43s | |
| β οΈ REPOSITORY | devskim | yes | 61 | 1.26s | |
| β REPOSITORY | dustilock | yes | no | 2.08s | |
| β REPOSITORY | git_diff | yes | no | 0.07s | |
| β REPOSITORY | secretlint | yes | no | 7.64s | |
| β REPOSITORY | syft | yes | no | 0.87s | |
| β REPOSITORY | trivy | yes | no | 23.6s | |
| β SPELL | cspell | 753 | 0 | 19.04s | |
| β SPELL | misspell | 572 | 2 | 0 | 0.52s |
| β XML | xmllint | 3 | 0 | 0 | 0.03s |
| β YAML | prettier | 81 | 0 | 0 | 2.72s |
| β YAML | v8r | 23 | 0 | 65.29s | |
| β YAML | yamllint | 82 | 0 | 1.33s |
See detailed report in MegaLinter reports
You could have same capabilities but better runtime performances if you request a new MegaLinter flavor.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
If you think this pull request should stay open, please remove the O: stale π€ label or comment on the pull request.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
If you think this pull request should stay open, please remove the O: stale π€ label or comment on the pull request.
/build
Command run output Build command workflow started. Installing dependencies Running script
./build.shBuild command workflow completed updating files.
/build
Command run output Build command workflow started. Installing dependencies Running script
./build.shBuild command workflow completed without updating files.
/build ref=docker-user
Command run output Build command workflow started. Installing dependencies Running script
./build.shBuild command workflow completed updating files.
/build ref=docker-user
Command run output Build command workflow started. Installing dependencies Running script
./build.shBuild command workflow completed updating files.
/build ref=docker-user
Command run output Build command workflow started. Installing dependencies Running script
./build.shBuild command workflow completed updating files.
Would love to see this merged as there seems to be no way to run megalinter without it trashing the current file permissions.
I was never able to figure out why the tests where failing, but would love to get this wrapped up if anybody understands what is going on. We use rootless-docker both for improved security and to avoid modifying file ownership.
Any news on this?
If @Kurt-von-Laven (or any motivated contributor like you ?) finds some available time, it could move again :)
On my side, my docker level is not advanced enough to handle the task :/