Skip to content

Commit cfbf566

Browse files
authored
Merge branch 'master' into main
2 parents 1b7c3d4 + ccdfc81 commit cfbf566

File tree

11 files changed

+254
-161
lines changed

11 files changed

+254
-161
lines changed

.github/dependabot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# .github/dependabot.yml
2+
#
3+
# Formal configuration for Dependabot to automate supply chain security.
4+
5+
version: 2
6+
updates:
7+
# 1. Check for updates to the npm dependencies (e.g., @google/gemini-cli)
8+
# This ensures our core tool is always patched and up-to-date.
9+
- package-ecosystem: "npm"
10+
directory: "/" # Location of package.json
11+
schedule:
12+
interval: "weekly"
13+
# Assign reviewers or labels if needed
14+
# reviewers:
15+
# - "kalvinparker"
16+
17+
# 2. Check for updates to the Docker base image (node:22-alpine)
18+
# This is critical for patching OS-level vulnerabilities in our container.
19+
- package-ecosystem: "docker"
20+
directory: "/" # Location of Dockerfile
21+
schedule:
22+
interval: "daily"
23+
24+
# 3. Check for updates to our GitHub Actions
25+
# This mitigates the risk of vulnerabilities in our CI/CD pipeline itself.
26+
- package-ecosystem: "github-actions"
27+
directory: "/" # Location of workflow files
28+
schedule:
29+
interval: "weekly"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# .github/workflows/build-and-scan.yml
2+
3+
name: Build and Scan Image
4+
5+
# This workflow runs on every push to main and on every pull request
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
permissions:
13+
contents: read # Required to check out the code
14+
15+
jobs:
16+
build-and-scan:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v5
21+
22+
# STEP 1: Build the image and load it into the local runner daemon.
23+
# The 'load: true' command is the critical fix.
24+
- name: Build and load local image
25+
uses: docker/build-push-action@v6
26+
with:
27+
context: .
28+
load: true
29+
# We give it a temporary, predictable tag for the next step.
30+
tags: secure-gemini-cli:scan-target
31+
32+
# STEP 2: Scan the image that was just built and loaded.
33+
# This step will now find the image 'secure-gemini-cli:scan-target'.
34+
- name: Scan image with Trivy
35+
uses: aquasecurity/[email protected]
36+
with:
37+
image-ref: 'secure-gemini-cli:scan-target'
38+
format: 'table'
39+
exit-code: '1'
40+
ignore-unfixed: true
41+
vuln-type: 'os,library'
42+
severity: 'CRITICAL,HIGH'

.github/workflows/pr-scan.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

DELETE.md

Whitespace-only changes.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Start from the official, minimal base image
2-
FROM node:22-alpine
2+
FROM node:25-alpine
33

44
# Remediate known base-image vulnerabilities (CR-20251013-04)
55
RUN apk update && apk upgrade busybox

README.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,36 @@ This project isn't just a `Dockerfile`; it's a complete, secure software lifecyc
1313
-**Hardened Base Image:** Built on `node:22-alpine` and patches OS packages (`apk upgrade`) during the build to mitigate known vulnerabilities.
1414
-**Supply Chain Scanned:** Runs `npm audit` as a mandatory, blocking security gate during the Docker build.
1515
-**Least Privilege:** Creates and runs as a dedicated, unprivileged `appuser` instead of `root`.
16-
-**Continuous Vulnerability Scanning:** A GitHub Actions workflow (`pr-scan.yml`) automatically scans every pull request with Trivy to prevent new vulnerabilities from being merged.
16+
-**Continuous Vulnerability Scanning:** A GitHub Actions workflow (`build-and-scan.yml`) automatically scans every pull request with Trivy to prevent new vulnerabilities from being merged.
1717
-**Automated Dependency Management:** Dependabot is configured to automatically create pull requests for updates to the base image, `npm` packages, and the CI/CD actions themselves.
1818
-**Formal Security Policies:** Includes a `SECURITY.md` file with a clear policy for vulnerability reporting.
1919

2020
## What is included
2121

22-
- `Dockerfile` — audited build that performs `apk` upgrades, updates `npm`, creates a non-root user, installs dependencies from `package.json`, runs `npm audit`, and sets the `ENTRYPOINT` to `npx gemini`.
23-
- `package.json` — minimal file with a dependency on `@google/gemini-cli`.
24-
- **`.github/workflows/`**: Contains two authoritative workflows:
25-
- **`pr-scan.yml`**: Builds and scans every pull request.
26-
- **`release.yml`**: Securely publishes a new versioned image to a container registry upon the creation of a GitHub Release.
22+
- **`Dockerfile`**: audited build that performs `apk` upgrades, updates `npm`, creates a non-root user, installs dependencies from `package.json`, runs `npm audit`, and sets the `ENTRYPOINT` to `npx gemini`.
23+
- **`package.json`**: minimal file with a dependency on `@google/gemini-cli`.
24+
- **`.github/workflows/`**: Contains one authoritative workflow:
25+
- **`build-and-scan.yml`**: Builds and scans every pull request. Securely publishes a new versioned image to a container registry upon the creation of a GitHub Release.
2726
- **`.github/dependabot.yml`**: Configuration for automated dependency updates.
2827
- **`SECURITY.md`**: The official security policy for the project.
29-
```
3028

31-
- The Dockerfile runs `npm audit` during build. In CI you may want to tune the audit policy or run more advanced supply-chain scanning.
32-
- The image runs as a non-root user. Confirm that any filesystem paths and environment variables used by `gemini` are writable by `appuser`.
33-
```markdown
29+
The Dockerfile runs `npm audit` during build. In CI you may want to tune the audit policy or run more advanced supply-chain scanning. The image runs as a non-root user. Confirm that any filesystem paths and environment variables used by `gemini` are writable by `appuser`.
30+
3431
## Image summary (from last local scan)
3532

3633
- Image: `secure-gemini-cli:latest`
3734
- OS: alpine 3.22.2
3835
- Size: ~656.6 MB
3936
- Trivy scan report (full JSON): `trivy-report.json` (saved in the project root)
4037

41-
Trivy findings (quick summary):
42-
43-
- I parsed and searched the saved `trivy-report.json` in this repository for vulnerability records. No vulnerability objects were found in the report.
44-
45-
Severity counts (from `trivy-report.json`):
46-
47-
- CRITICAL: 0
48-
- HIGH: 0
49-
- MEDIUM: 0
50-
- LOW: 0
51-
- UNKNOWN: 0
52-
5338
If you'd like a deeper supply-chain audit (for example, run `npm audit` locally and attempt auto-fixes, or re-run Trivy with a different policy), I can add step-by-step remediation guidance. Otherwise this image's saved scan contains no findings to triage.
5439

5540
## Build locally
5641

5742
Run the following from the `secure-gemini` directory:
5843

5944
```powershell
60-
docker build -t secure-gemini-cli:latest .
45+
docker build -t secure-gemini-cli:latest
6146
```
6247

6348
If `npm audit` fails during the Docker build (it may, depending on transient vulnerabilities), you can temporarily allow the build to continue locally by changing the Dockerfile audit step to a non-blocking command (not recommended for CI):
@@ -70,12 +55,16 @@ I recommend addressing audit findings before publishing the image.
7055

7156
## Run
7257

58+
This image is hosted on GitHub Container Registry (GHCR) and requires a GitHub Personal Access Token (PAT) with the `read:packages` scope for authentication.
59+
60+
**Full instructions on token creation and running the image can be found in [USAGE.md](USAGE.md).**
61+
62+
The final command requires your Gemini API key:
63+
7364
```powershell
74-
docker run --rm secure-gemini-cli:latest --help
65+
docker run -it --rm -e GEMINI_API_KEY="YOUR-GEMINI-API-KEY" secure-gemini-cli:latest
7566
```
7667

77-
Because the image uses `npx` as the entrypoint it will run the `gemini` CLI.
78-
7968
## How to re-run Trivy locally
8069

8170
If you want to re-run the Trivy scan locally (recommended after changes):
@@ -94,10 +83,10 @@ docker run --rm aquasec/trivy:latest image secure-gemini-cli:latest
9483

9584
## Git / Commit
9685

97-
If you'd like to commit the approved configuration locally, run these PowerShell steps (replace `<your-username>` when adding the remote):
86+
If you'd like to commit the approved configuration locally, run these PowerShell steps (replace `<folder-location>` and `<your-username>` when adding the remote):
9887

9988
```powershell
100-
cd "D:\My Documents\Docker Projects\secure-gemini"
89+
cd "<folder-location>"
10190
# create .gitignore if you haven't already
10291
@"
10392
node_modules/
@@ -121,13 +110,29 @@ git push -u origin main
121110

122111
## CI: Build and scan
123112

124-
A GitHub Actions workflow (`.github/workflows/docker-build-scan.yml`) is included to build and scan the image with Trivy on push to `main`. This performs an automated check and can be adjusted to fail the build on specific severities.
113+
A GitHub Actions workflow (`.github/workflows/build-and-scan.yml`) is included to build and scan the image with Trivy on push to `main`. This performs an automated check and can be adjusted to fail the build on specific severities.
125114

126-
To publish the image from CI (GHCR / Docker Hub), add the appropriate secrets to your repository and enable the `docker-build-scan-publish.yml` workflow. Required secrets for Docker Hub: `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` (or use GHCR with `GITHUB_TOKEN`).
115+
To publish the image from CI (GHCR / Docker Hub), add the appropriate secrets to your repository and enable the `build-and-scan.yml` workflow. Required secrets for Docker Hub: `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` (or use GHCR with `GITHUB_TOKEN`).
127116

128117
## Notes
129118

130119
- The Dockerfile runs `npm audit` during build. In CI you may want to tune the audit policy or run more advanced supply-chain scanning.
131120
- The image runs as a non-root user. Confirm that any filesystem paths and environment variables used by `gemini` are writable by `appuser`.
132121

122+
### Key Milestones Achieved:
123+
124+
1. Strategy: Shifted from an insecure, ad-hoc installation to a secure, containerised architecture.
125+
126+
2. Governance: Established a formal SECURITY.md policy, a LICENSE, and README.md documentation.
127+
128+
3. Hardening: Implemented base image vulnerability patching and least-privilege (non-root) execution.
129+
130+
4. Supply Chain Security: Integrated mandatory npm audit security gates and a robust `build-and-scan.yml` workflow with Trivy.
131+
132+
5. Configuration Management: Codified the entire secure build process in a version-controlled Dockerfile and Git repository.
133+
134+
6. Automation: Deployed a full CI/CD pipeline for secure releases and configured Dependabot for proactive, automated dependency management.
135+
136+
7. Verification: Successfully validated the entire process with a final, successful local build.
137+
133138
---

SECURITY.md

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,36 @@
11
# Security Policy
22

3-
This document provides the high-level security policy for projects that use the `profile-template` as their base. It is intended to be a canonical, easy-to-find security statement that repository owners can adapt per-repo where necessary.
3+
This document outlines the security policy for the `secure-gemini` project.
44

55
## Supported Versions
66

7-
Security support depends on the project's branch or release strategy. Repository maintainers should keep their project's dependencies and CI/CD configurations up to date.
7+
This project provides a configuration (`Dockerfile`) for building a secure container image. The security of the final image is dependent on the versions of the components at build time. I am committed to keeping the configuration in the `main` branch up-to-date with the latest secure practices.
88

9-
| Version | Supported |
10-
| ------- | --------- |
11-
| `main` (or `master`) branch | :white_check_mark: |
9+
| Version | Supported |
10+
| ------- | ------------------ |
11+
| `master` branch | :white_check_mark: |
1212
| Releases (Tags) | :white_check_mark: |
13-
| Older commits | :x: |
13+
| Older commits | :x: |
1414

15-
Users are responsible for pulling the latest changes and rebuilding any artifacts (for example container images) to receive security updates.
15+
**User Responsibility:** Users are responsible for pulling the latest changes from the `master` branch and rebuilding their images to ensure they have the most recent security patches and dependency versions. My CI/CD pipeline (`pr-scan.yml`) continuously validates the security of the `main` branch.
1616

1717
## Reporting a Vulnerability
1818

19-
We take security vulnerabilities seriously and prefer coordinated disclosure. Please do not file security reports as public issues.
19+
I take all security vulnerabilities seriously. I believe in coordinated disclosure and appreciate the community's help in keeping our project secure.
2020

21-
Preferred reporting methods:
21+
**How to Report a Vulnerability:**
2222

23-
1. Use GitHub's private vulnerability reporting feature (the "Security" tab) when available.
24-
2. Email the primary maintainer. (Update the email address in the repository's README to a monitored address.)
23+
Please **DO NOT** report security vulnerabilities through public GitHub issues.
2524

26-
What to expect from us:
25+
Instead, please report them directly via one of the following methods:
26+
* **Primary Method:** Use GitHub's private vulnerability reporting feature, available under the "Security" tab of this repository.
2727

28-
1. Acknowledge receipt within 72 hours.
29-
2. Provide an initial assessment of impact and validity.
30-
3. Work on a fix and provide updates until a patch is released.
31-
4. Coordinate public disclosure after a fix is published.
28+
**What to Expect:**
3229

33-
## Security responsibilities
30+
When you report a vulnerability, I will make every effort to:
31+
1. Acknowledge receipt of your report within 72 hours.
32+
2. Provide an initial assessment of the vulnerability's validity and impact.
33+
3. If the vulnerability is accepted, I will work on a fix and aim to release a patch.
34+
4. Keep you informed of our progress. I will coordinate with you on the public disclosure of the vulnerability after a fix has been released.
3435

35-
Maintainers should:
36-
37-
- Keep CI workflows (tests, linting, and security scanners) up to date.
38-
- Regularly update base images and dependencies.
39-
- Use secret scanning and dependency vulnerability scanning where available.
40-
- Provide clear instructions for reproducing and verifying fixes.
41-
42-
If you are a contributor or user with security questions, please consult this document and contact the maintainers using the reporting methods above.
43-
44-
## Repository
45-
46-
Repository: `profile-template`
47-
48-
Primary contacts / maintainers: [email protected]
36+
I am committed to a transparent and timely response. Thank you for helping to keep this project secure.

0 commit comments

Comments
 (0)