Skip to content
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

feature #10: add Dockerfile and docker-compose.yml #11

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/main-workflow.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Create and publish a Docker image
run-name: ${{ github.actor }} is creating and publishing a Docker image

on:
release:
types: [ published ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
environment: Default
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6.9.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.12-alpine

LABEL mantainer="cob0"\
org.opencontainers.image.authors="cob0 <cob0@tutanota.com>"\
org.opencontainers.image.title="dep-scan-threshold-analyzer"\
org.opencontainers.image.description="A binary tool that verifies if vulnerability reports generated by dep-scan comply with predefined security thresholds. It outputs OK if the vulnerabilities are within the threshold or FAIL if they exceed the allowed values."\
org.opencontainers.image.source="https://github.com/cob0/dep-scan-threshold-analyzer"\
org.opencontainers.image.version="1.0.0"\
org.opencontainers.image.licenses=GPLv3

COPY . /opt/dep-scan-threshold-analyzer
WORKDIR /opt/dep-scan-threshold-analyzer

ENTRYPOINT [ "python" ]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
░▀█▀░█░█░█▀▄░█▀▀░█▀▀░█░█░█▀█░█░░░█▀▄
░░█░░█▀█░█▀▄░█▀▀░▀▀█░█▀█░█░█░█░░░█░█
░░▀░░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀░
░█▀█░█▀█░█▀█░█░░░█░█░▀▀█░█▀▀░█▀▄
░█▀█░█░█░█▀█░█░░░░█░░▄▀░░█▀▀░█▀▄
░▀░▀░▀░▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀░▀
░█▀█░█▀█░█▀█░█░░░█░█░▀▀█░█▀▀░█▀▄░░░░
░█▀█░█░█░█▀█░█░░░░█░░▄▀░░█▀▀░█▀▄░░░░
░▀░▀░▀░▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀░▀░░░░
v1.0.0

A binary tool that verifies if vulnerability reports generated by dep-scan comply with predefined security thresholds.
Expand Down
2 changes: 1 addition & 1 deletion depscan/analyzer/thresholdanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run(self) -> bool:
if cvss_score >= self.threshold:
self.logger.error(
f"One or more dependencies were identified with vulnerabilities that have a CVSS score greater than or equal to '{self.threshold}'")
return False
return True
except FileNotFoundError:
self.logger.warning("There are no report files in the reports folder")

Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
dep-scan-threshold-analyzer:
build: .
entrypoint: python
command: dep_scan_threshold_analyzer.py -f reports/sbom-java.vdr.json -t 5
network_mode: none
restart: "no"
6 changes: 3 additions & 3 deletions log/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def print_logo() -> None:
░▀█▀░█░█░█▀▄░█▀▀░█▀▀░█░█░█▀█░█░░░█▀▄
░░█░░█▀█░█▀▄░█▀▀░▀▀█░█▀█░█░█░█░░░█░█
░░▀░░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀░
░█▀█░█▀█░█▀█░█░░░█░█░▀▀█░█▀▀░█▀▄
░█▀█░█░█░█▀█░█░░░░█░░▄▀░░█▀▀░█▀▄
░▀░▀░▀░▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀░▀
░█▀█░█▀█░█▀█░█░░░█░█░▀▀█░█▀▀░█▀▄░░░░
░█▀█░█░█░█▀█░█░░░░█░░▄▀░░█▀▀░█▀▄░░░░
░▀░▀░▀░▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀░▀░░░░
v1.0.0
""")