-
Notifications
You must be signed in to change notification settings - Fork 9
DRAFT: Address CVE in Dockerfile #62
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .git* | ||
| *.md | ||
| *test*.* | ||
| Dockerfile | ||
| LICENSE |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,106 @@ | ||||||||||||||||||||||||||||||
| name: PR Security Scan | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||
| pull_request_target: | ||||||||||||||||||||||||||||||
| types: [opened, synchronize, reopened] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||
| scan: | ||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||
| - name: Check out code | ||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| ref: ${{ github.event.pull_request.head.sha }} | ||||||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||||||
| submodules: 'recursive' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Build the Docker image | ||||||||||||||||||||||||||||||
| uses: docker/build-push-action@v5 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| context: . | ||||||||||||||||||||||||||||||
| push: false | ||||||||||||||||||||||||||||||
| load: true | ||||||||||||||||||||||||||||||
| tags: pr_image:${{ github.sha }} | ||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd /tmp && find . -name "pr-scan.yml" 2>/dev/null || echo "Not in /tmp, checking repo"Repository: appwrite/docker-base Length of output: 46 🏁 Script executed: find . -name "pr-scan.yml" -type f 2>/dev/nullRepository: appwrite/docker-base Length of output: 95 🏁 Script executed: cat -n .github/workflows/pr-scan.yml 2>/dev/null || echo "File not found, listing directory"Repository: appwrite/docker-base Length of output: 4676 🏁 Script executed: ls -la .github/workflows/ 2>/dev/null || echo "No workflows directory"Repository: appwrite/docker-base Length of output: 363 Do not run untrusted PR code under This workflow checks out 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Run Trivy vulnerability scanner on image | ||||||||||||||||||||||||||||||
| uses: aquasecurity/trivy-action@0.20.0 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| image-ref: 'pr_image:${{ github.sha }}' | ||||||||||||||||||||||||||||||
| format: 'json' | ||||||||||||||||||||||||||||||
| output: 'trivy-image-results.json' | ||||||||||||||||||||||||||||||
| severity: 'CRITICAL,HIGH' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Run Trivy vulnerability scanner on source code | ||||||||||||||||||||||||||||||
| uses: aquasecurity/trivy-action@0.20.0 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| scan-type: 'fs' | ||||||||||||||||||||||||||||||
| scan-ref: '.' | ||||||||||||||||||||||||||||||
| format: 'json' | ||||||||||||||||||||||||||||||
| output: 'trivy-fs-results.json' | ||||||||||||||||||||||||||||||
| severity: 'CRITICAL,HIGH' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Process Trivy scan results | ||||||||||||||||||||||||||||||
| id: process-results | ||||||||||||||||||||||||||||||
| uses: actions/github-script@v7 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||||||||||||||||
| let commentBody = '## Security Scan Results for PR\n\n'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| function processResults(results, title) { | ||||||||||||||||||||||||||||||
| let sectionBody = `### ${title}\n\n`; | ||||||||||||||||||||||||||||||
| if (results.Results && results.Results.some(result => result.Vulnerabilities && result.Vulnerabilities.length > 0)) { | ||||||||||||||||||||||||||||||
| sectionBody += '| Package | Version | Vulnerability | Severity |\n'; | ||||||||||||||||||||||||||||||
| sectionBody += '|---------|---------|----------------|----------|\n'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const uniqueVulns = new Set(); | ||||||||||||||||||||||||||||||
| results.Results.forEach(result => { | ||||||||||||||||||||||||||||||
| if (result.Vulnerabilities) { | ||||||||||||||||||||||||||||||
| result.Vulnerabilities.forEach(vuln => { | ||||||||||||||||||||||||||||||
| const vulnKey = `${vuln.PkgName}-${vuln.InstalledVersion}-${vuln.VulnerabilityID}`; | ||||||||||||||||||||||||||||||
| if (!uniqueVulns.has(vulnKey)) { | ||||||||||||||||||||||||||||||
| uniqueVulns.add(vulnKey); | ||||||||||||||||||||||||||||||
| sectionBody += `| ${vuln.PkgName} | ${vuln.InstalledVersion} | [${vuln.VulnerabilityID}](https://nvd.nist.gov/vuln/detail/${vuln.VulnerabilityID}) | ${vuln.Severity} |\n`; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| sectionBody += '🎉 No vulnerabilities found!\n'; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| return sectionBody; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||
| const imageResults = JSON.parse(fs.readFileSync('trivy-image-results.json', 'utf8')); | ||||||||||||||||||||||||||||||
| const fsResults = JSON.parse(fs.readFileSync('trivy-fs-results.json', 'utf8')); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| commentBody += processResults(imageResults, "Docker Image Scan Results"); | ||||||||||||||||||||||||||||||
| commentBody += '\n'; | ||||||||||||||||||||||||||||||
| commentBody += processResults(fsResults, "Source Code Scan Results"); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||
| commentBody += `There was an error while running the security scan: ${error.message}\n`; | ||||||||||||||||||||||||||||||
| commentBody += 'Please contact the core team for assistance.'; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| core.setOutput('comment-body', commentBody); | ||||||||||||||||||||||||||||||
| - name: Find Comment | ||||||||||||||||||||||||||||||
| uses: peter-evans/find-comment@v3 | ||||||||||||||||||||||||||||||
| id: fc | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| issue-number: ${{ github.event.pull_request.number }} | ||||||||||||||||||||||||||||||
| comment-author: 'github-actions[bot]' | ||||||||||||||||||||||||||||||
| body-includes: Security Scan Results for PR | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Create or update comment | ||||||||||||||||||||||||||||||
| uses: peter-evans/create-or-update-comment@v3 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| issue-number: ${{ github.event.pull_request.number }} | ||||||||||||||||||||||||||||||
| comment-id: ${{ steps.fc.outputs.comment-id }} | ||||||||||||||||||||||||||||||
| body: ${{ steps.process-results.outputs.comment-body }} | ||||||||||||||||||||||||||||||
| edit-mode: replace | ||||||||||||||||||||||||||||||
|
Comment on lines
+100
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Latest peter-evans/create-or-update-comment GitHub Action version is v5.0.0 (tag v5). [1] Use:
Sources Citations:
Update action to v5: The action version Suggested fix - name: Create or update comment
- uses: peter-evans/create-or-update-comment@v3
+ uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.11)[error] 92-92: the runner of "peter-evans/create-or-update-comment@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| .idea | ||
| *.logs | ||
| NOTES*.md | ||
| trivy-*-results.json |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,60 +1,75 @@ | ||||||||||||||||||||||||||||
| # Docker Base | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| [](https://travis-ci.com/appwrite/docker-base) | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if there are any Travis CI configuration files in the repository
fd -t f '.travis.yml' || echo "No Travis CI config found"
# Check for GitHub Actions workflows
fd -t f -e yml -e yaml . .github/workflows/ 2>/dev/null || echo "No GitHub workflows directory"Repository: appwrite/docker-base Length of output: 163 🏁 Script executed: head -n 5 README.mdRepository: appwrite/docker-base Length of output: 479 Update CI badge to reflect current CI system. The badge on line 3 references Travis CI ( 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| [](https://appwrite.io/discord) | ||||||||||||||||||||||||||||
| [](https://hub.docker.com/r/appwrite/base) | ||||||||||||||||||||||||||||
| [](https://travis-ci.com/appwrite/docker-base) | ||||||||||||||||||||||||||||
| [](https://twitter.com/appwrite) | ||||||||||||||||||||||||||||
| [](https://stackshare.io/appwrite) | ||||||||||||||||||||||||||||
| [](https://twitter.com/appwrite) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| [Appwrite](https://appwrite.io) base docker image with applications and extensions built and installed. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Getting Started | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| These instructions will cover usage information to help your run Appwrite's base docker container. | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix grammar typo: "help your run" → "help you run". Suggested fix-These instructions will cover usage information to help your run Appwrite's base docker container.
+These instructions will cover usage information to help you run Appwrite's base docker container.🧰 Tools🪛 LanguageTool[grammar] ~13-~13: Ensure spelling is correct (QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Prerequisites | ||||||||||||||||||||||||||||
| ### NOTE | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| In order to run this container you'll need docker installed. | ||||||||||||||||||||||||||||
| * For example usage `latest` is stated in the commands. The Appwrite team recommends using pinned version releases outside of development. | ||||||||||||||||||||||||||||
| * We use `Docker` but you may use any compatible container runtime in its place. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Prerequisites | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| In order to run this container you'll need the Docker runtime installed. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Docker** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| * [Windows](https://docs.docker.com/windows/started) | ||||||||||||||||||||||||||||
| * [OS X](https://docs.docker.com/mac/started/) | ||||||||||||||||||||||||||||
| * [Linux](https://docs.docker.com/linux/started/) | ||||||||||||||||||||||||||||
| * [OS X](https://docs.docker.com/mac/started/) | ||||||||||||||||||||||||||||
| * [Windows](https://docs.docker.com/windows/started) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Usage | ||||||||||||||||||||||||||||
| * [Docker buildx](https://github.com/docker/buildx) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||
| docker run appwrite/base | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| **Optional** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Testing | ||||||||||||||||||||||||||||
| * [GoogleContainerTools/container-structure-test](https://github.com/GoogleContainerTools/container-structure-test) for testing | ||||||||||||||||||||||||||||
| * [Trivy](https://trivy.dev/) for CVE scanning | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| We use [Container Structure Test](https://github.com/GoogleContainerTools/container-structure-test) to run test for the docker image. In order to run test first install Container strucutre test using the following command. | ||||||||||||||||||||||||||||
| ## Build | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test | ||||||||||||||||||||||||||||
| Typical building. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||
| docker buildx build --tag appwrite/base:latest . | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
Comment on lines
+37
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The build command does not reliably produce the local image used below. The later Scan/Test/Run/Push sections all assume Suggested doc fix-docker buildx build --tag appwrite/base:latest .
+docker buildx build --load --tag appwrite/base:latest .📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Run Test | ||||||||||||||||||||||||||||
| Multi-arch building. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| First build and tag the docker image and then run the test using the configuration file. | ||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||
| docker buildx build --platform linux/amd64,linux/arm64/v8,linux/ppc64le --push --tag appwrite/base:latest . | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| docker build -t appwrite-base-test . | ||||||||||||||||||||||||||||
| container-structure-test test --config tests.yaml --image appwrite-base-test | ||||||||||||||||||||||||||||
| ## Scan | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||
| trivy image --format json --pkg-types os,library --severity CRITICAL,HIGH --output trivy-image-results.json appwrite/base:latest | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Build | ||||||||||||||||||||||||||||
| ## Test | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| docker build --tag appwrite/base:1.0.0 . | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| docker push appwrite/base:1.0.0 | ||||||||||||||||||||||||||||
| container-structure-test test --config tests.yaml --image appwrite/base:latest | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Multi-arch build (using [buildx](https://github.com/docker/buildx)): | ||||||||||||||||||||||||||||
| ## Run | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```shell | ||||||||||||||||||||||||||||
| docker run appwrite/base:latest | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| docker buildx build --platform linux/amd64,linux/arm64/v8,linux/ppc64le --tag appwrite/base:1.0.0 --push . | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Push | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| docker push appwrite/base:latest | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Find Us | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Check failure
Code scanning / CodeQL
Checkout of untrusted code in trusted context High