Skip to content

Commit 434cdee

Browse files
committed
resolve merge conflicts: keep new security advisories implementation
2 parents 91c311a + 92cf8b0 commit 434cdee

File tree

20 files changed

+488
-47
lines changed

20 files changed

+488
-47
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
config.yml
2+
evaluation_results
3+
.github
4+
.goreleaser.yml
5+
.gitignore
6+
example-config.yml
7+
github-repo
8+
*.png
9+
*.md

.github/CONTRIBUTING.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@ We'd love to accept your patches and contributions to this project. There are ju
66

77
Participation in this project comes under the [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md)
88

9+
## Local Development
10+
11+
While working on tests, the best way to run the plugin is via `go run . debug --service=<your-service>`. Ensure your local `config` file is set up correctly beforehand.
12+
13+
You may also pull the code locally and run the local Dockerfile:
14+
15+
1. Pull the repo
16+
2. Modify `example-config.yml` to use your values, and rename it to `config.yml`
17+
3. Build the Docker Image: `make docker-build`
18+
4. Run the Docker Image: `make docker-run`
19+
5. Review the output in the directory you've specified in your config file
20+
21+
## Required Token Scopes
22+
23+
![Token Scopes](../token-scopes.png)
24+
925
## Code Submission
1026

1127
Thank you for considering submitting code to Privateer!
1228

1329
- We follow the [GitHub Pull Request Model](https://help.github.com/articles/about-pull-requests/) for all contributions.
14-
- For large bodies of work, we recommend creating an issue using the "Feature Request" template to outline the feature that you wish to build, and describe how it will be implemented. This gives a chance for review to happen early, and ensures no wasted effort occurs.
15-
- For new features, documentation must be included. Currently we do not have a formalized documentation process, so please use your best judgment until a process is in place.
1630
- All submissions, including submissions by project members, will require review before being merged.
17-
- Once review has occurred, please rebase your PR down to a single commit. This will ensure a nice clean Git history.
1831
- Please write a [good Git Commit message](https://chris.beams.io/posts/git-commit/)
1932
- Please follow the code formatting instructions below
2033

.github/workflows/build.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111
pull-requests: read
1212

1313
jobs:
14-
lint:
14+
build:
1515
name: build
1616
runs-on: ubuntu-latest
1717
steps:
@@ -24,4 +24,19 @@ jobs:
2424
- name: build
2525
run: make build
2626
- name: test
27-
run: make test-cov
27+
run: make test-cov
28+
- name: test coverage check
29+
env:
30+
TESTCOVERAGE_THRESHOLD: 26
31+
run: |
32+
echo "Quality Gate: checking test coverage is above threshold ..."
33+
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
34+
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
35+
echo "Current test coverage : $totalCoverage %"
36+
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 >= $2)}') )); then
37+
echo "OK"
38+
else
39+
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
40+
echo "Failed"
41+
exit 1
42+
fi

.github/workflows/docker-ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Docker CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'Dockerfile'
7+
- '.dockerignore'
8+
pull_request:
9+
paths:
10+
- 'Dockerfile'
11+
- '.dockerignore'
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v5
21+
with:
22+
persist-credentials: false
23+
- name: Set up buildx
24+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
25+
- name: Build container image
26+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
27+
with:
28+
context: .
29+
file: ./Dockerfile
30+
push: false

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- name: golangci-lint
2525
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9
2626
with:
27-
version: v2.1
27+
version: v2.5.0

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ jobs:
2020
needs: release
2121
runs-on: ubuntu-latest
2222
permissions:
23+
attestations: write
2324
contents: write
25+
id-token: write
26+
outputs:
27+
attestation_matrix: ${{ steps.generate_matrix.outputs.matrix }}
2428
steps:
2529
- name: Checkout
2630
uses: actions/checkout@v5
@@ -31,6 +35,10 @@ jobs:
3135
uses: actions/setup-go@v5
3236
with:
3337
go-version: 1.23.4
38+
- name: Install Syft
39+
uses: anchore/sbom-action/download-syft@f8bdd1d8ac5e901a77a92f111440fdb1b593736b
40+
with:
41+
syft-version: v1.33.0
3442
- name: Run GoReleaser
3543
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a
3644
with:
@@ -39,3 +47,36 @@ jobs:
3947
args: release --clean
4048
env:
4149
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
- name: Attest Build Provenance
51+
uses: actions/attest-build-provenance@v3
52+
with:
53+
subject-checksums: dist/checksums.txt
54+
- name: Generate attestation matrix
55+
id: generate_matrix
56+
run: |
57+
matrix=$(ls dist/*.spdx.json | jq -R '{"sbom": ., "archive": sub("\\.spdx\\.json$"; "")}' | jq -s -c '{"include": .}')
58+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
59+
- name: Upload artifacts
60+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
61+
with:
62+
name: dist
63+
path: dist
64+
attest-sboms:
65+
needs: goreleaser
66+
runs-on: ubuntu-latest
67+
permissions:
68+
attestations: write
69+
id-token: write
70+
strategy:
71+
matrix: ${{ fromJson(needs.goreleaser.outputs.attestation_matrix) }}
72+
steps:
73+
- name: Download artifacts
74+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
75+
with:
76+
name: dist
77+
path: dist
78+
- name: Attest SBOM
79+
uses: actions/attest-sbom@4651f806c01d8637787e274ac3bdf724ef169f34
80+
with:
81+
subject-path: "${{ matrix.archive }}"
82+
sbom-path: "${{ matrix.sbom }}"

.goreleaser.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,66 @@ changelog:
4242
- "^docs:"
4343
- "^test:"
4444

45+
checksum:
46+
name_template: "checksums.txt"
47+
4548
release:
4649
prerelease: auto
4750

51+
sboms:
52+
- # ID of the sbom config, must be unique.
53+
#
54+
# Default: 'default'.
55+
id: sboms
56+
57+
# List of names of the SBOM documents created at this step
58+
# (relative to the dist dir).
59+
#
60+
# Each element configured is made available as variables. For example:
61+
# documents: ["foo", "bar"]
62+
#
63+
# would make the following variables that can be referenced as template keys:
64+
# document0: "foo"
65+
# document1: "bar"
66+
#
67+
# Note that multiple sbom values are only allowed if the value of
68+
# "artifacts" is "any".
69+
#
70+
# Default:
71+
# When "binary": ["{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}.sbom.json"]
72+
# When "any": []
73+
# Otherwise: ["{{ .ArtifactName }}.sbom.json"]
74+
# Templates: allowed.
75+
documents:
76+
- "${artifact}.spdx.json"
77+
78+
# Path to the SBOM generator command
79+
#
80+
# Note: the process CWD will be set to the same location as "dist"
81+
#
82+
# Default: 'syft'.
83+
cmd: syft
84+
85+
# Command line arguments for the command
86+
#
87+
# Default: ["$artifact", "--output", "spdx-json=$document", "--enrich", "all"].
88+
# Templates: allowed.
89+
# args: ["$artifact", "--output", "cyclonedx-json=$document"]
90+
91+
# Which artifacts to catalog.
92+
#
93+
# Valid options are:
94+
# - any: let the SBOM tool decide which artifacts available in
95+
# the cwd should be cataloged
96+
# - source: source archive
97+
# - package: Linux packages (deb, rpm, apk, etc)
98+
# - installer: Windows MSI installers (Pro only)
99+
# - diskimage: macOS DMG disk images (Pro only)
100+
# - archive: archives from archive pipe
101+
# - binary: binaries output from the build stage
102+
#
103+
# Default: 'archive'.
104+
artifacts: archive
105+
48106
universal_binaries:
49107
- replace: true

Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
FROM alpine:3.21 AS core
1+
FROM alpine:3.22 AS core
22
RUN apk add --no-cache wget tar unzip
33

44
WORKDIR /app
5-
ARG VERSION=0.7.0
5+
ARG VERSION=0.9.1
66
ARG PLATFORM=Linux_x86_64 # Change this based on your target system
77

88
RUN wget https://github.com/privateerproj/privateer/releases/download/v${VERSION}/privateer_${PLATFORM}.tar.gz
99
RUN tar -xzf privateer_${PLATFORM}.tar.gz
1010

11-
FROM golang:1.23.4-alpine3.21 AS plugin
11+
FROM golang:1.25.1-alpine3.22 AS plugin
1212
RUN apk add --no-cache make git
1313
WORKDIR /plugin
1414
COPY . .
1515
RUN make binary
1616

17-
FROM golang:1.23.4-alpine3.21
18-
RUN apk add --no-cache make git && \
19-
mkdir -p /.privateer/bin
17+
FROM golang:1.25.1-alpine3.22
18+
RUN addgroup -g 1001 -S appgroup && adduser -u 1001 -S appuser -G appgroup
19+
20+
RUN mkdir -p /.privateer/bin && chown -R appuser:appgroup /.privateer
2021
WORKDIR /.privateer/bin
22+
USER appuser
23+
2124
COPY --from=core /app/privateer .
2225
COPY --from=plugin /plugin/github-repo .
2326
COPY --from=plugin /plugin/container-entrypoint.sh .
2427

2528
# The config file must be provided at run time.
26-
# example: docker run -v /path/to/config.yml:/.privateer/bin/config.yml privateer-image
29+
# example: docker run -v /path/to/config.yml:/.privateer/config.yml privateer-image
2730
CMD ["./container-entrypoint.sh"]

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ BUILD_WIN=@env GOOS=windows GOARCH=amd64 go build -o $(PACKNAME).exe
44
BUILD_LINUX=@env GOOS=linux GOARCH=amd64 go build -o $(PACKNAME)
55
BUILD_MAC=@env GOOS=darwin GOARCH=amd64 go build -o $(PACKNAME)-darwin
66

7+
COVERAGE = $(shell go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+')
8+
79
release: package release bin
810
release-candidate: package release-candidate
911
binary: package build
@@ -35,21 +37,24 @@ build:
3537
package: tidy test
3638
@echo " > Packaging static files..."
3739

38-
test:
40+
vet:
3941
@echo " > Validating code ..."
4042
@go vet ./...
43+
44+
test: vet
4145
@go clean -testcache
4246
@go test ./...
4347

4448
tidy:
4549
@echo " > Tidying go.mod ..."
4650
@go mod tidy
4751

48-
test-cov:
52+
test-cov: vet
4953
@echo "Running tests and generating coverage output ..."
5054
@go test ./... -coverprofile coverage.out -covermode count
51-
@sleep 2 # Sleeping to allow for coverage.out file to get generated
52-
@echo "Current test coverage : $(shell go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+') %"
55+
56+
print-cov:
57+
@echo "Current test coverage : $(COVERAGE)%"
5358

5459
release-candidate: tidy test
5560
@echo " > Building release candidate for Linux..."

README.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
# Privateer Plugin for GitHub Repositories
22

3-
This plugin is designed to test a GitHub repository using automated assessments compatible with the [Gemara](https://github.com/ossf/gemara) Layer 4 data types.
3+
This application performs automated assessments against GitHub repositories using controls defined in the [Open Source Project Security Baseline v2025.02.25](https://baseline.openssf.org). The application consumes the OSPS Baseline controls using [Gemara](https://github.com/ossf/gemara) layer 2 and produces results of the automated assessments using layer 4.
44

5-
Many of the assessments require a [Security Insights](https://github.com/ossf/security-insights) file to be present at the root of the repository, or `./github/security-insights.yml`.
5+
Many of the assessments depend upon the presence of a [Security Insights](https://github.com/ossf/security-insights) file at the root of the repository, or `./github/security-insights.yml`.
66

77
## Work in Progress
88

9-
Assessment development is currently addressing the [Open Source Project Security Baseline v2025.02.25](https://baseline.openssf.org).
9+
Currently 39 control requirements across OSPS Baselines levels 1-3 are covered, with 13 not yet implemented. [Maturity Level 1](https://baseline.openssf.org/versions/2025-02-25.html#level-1) requirements are the most rigorously tested and are recommended for use. The results of these layer 1 assessments are integrated into [LFX Insights](https://insights.linuxfoundation.org/project/k8s/repository/kubernetes-kubernetes/security), powering the [Security & Best Practices results](https://insights.linuxfoundation.org/docs/metrics/security/).
1010

11-
As possible, the goal is to work on the OSPS Baseline maturity levels from the lowest to highest.
11+
![alt text](kubernetes_insights_baseline.png)
12+
13+
Level 2 and Level 3 requirements are undergoing current development and may be less rigorously tested.
14+
15+
## Docker Usage
16+
17+
```sh
18+
# build the image
19+
docker build . -t local
20+
docker run \
21+
--mount type=bind,source=./config.yml,destination=/.privateer/config.yml \
22+
--mount type=bind,source=./evaluation_results,destination=/.privateer/bin/evaluation_results \
23+
local
24+
```
1225

1326
## GitHub Actions Usage
1427

15-
We've pushed an image to docker hub for use in GitHub Actions. Many tests are currently pending implementation, and only `Maturity Level 1` is currently recommended for use.
28+
We've pushed an image to docker hub for use in GitHub Actions.
1629

1730
You will also need to set up a GitHub personal access token with the repository read permissions. This token should be added to your config file, or — if using the example pipeline below — as a secret in your repository.
1831

@@ -22,18 +35,10 @@ You will also need to set up a GitHub personal access token with the repository
2235
- [Workflow Definition](https://github.com/privateerproj/.github/blob/main/.github/workflows/osps-baseline.yml)
2336
- [Action Results](https://github.com/privateerproj/.github/actions/runs/13691384519/job/38285134201)
2437

25-
## Local Development
26-
27-
While working on tests, the best way to run the plugin is via `go run . debug --service=<your-service>`. Ensure your local `config` file is set up correctly beforehand.
28-
29-
You may also pull the code locally and run the local Dockerfile:
38+
## Contributing
3039

31-
1. Pull the repo
32-
2. Modify `example-config.yml` to use your values, and rename it to `config.yml`
33-
3. Build the Docker Image: `make docker-build`
34-
4. Run the Docker Image: `make docker-run`
35-
5. Review the output in the directory you've specified in your config file
40+
Contributions are welcome! Please see our [Contributing Guidelines](.github/CONTRIBUTING.md) for more information.
3641

37-
## Required Token Scopes
42+
## License
3843

39-
![Token Scopes](./token-scopes.png)
44+
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)