Skip to content

Commit d784707

Browse files
authored
Merge pull request #11 from scality/feature/refacto-python
Feature/refacto python
2 parents 6c6b720 + b3c18f5 commit d784707

File tree

18 files changed

+916
-135
lines changed

18 files changed

+916
-135
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
FROM mcr.microsoft.com/devcontainers/base:jammy
22

3-
RUN export DEBIAN_FRONTEND=noninteractive && \
4-
curl -O -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh && \
5-
sudo sh install.sh -b /usr/local/bin
6-
7-
RUN export DEBIAN_FRONTEND=noninteractive && \
8-
curl -O -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh && \
9-
sudo sh install.sh -b /usr/local/bin
10-
11-
RUN export DEBIAN_FRONTEND=noninteractive && \
12-
curl -O -sSfL https://aquasecurity.github.io/trivy-repo/deb/public.key && \
13-
sudo apt-key add public.key && \
14-
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | tee -a /etc/apt/sources.list.d/trivy.list
15-
163
RUN export DEBIAN_FRONTEND=noninteractive && \
174
apt-get update && \
185
apt-get install --no-install-recommends -y \
@@ -21,11 +8,14 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
218
bash-completion \
229
curl \
2310
git \
11+
python3-pip \
2412
p7zip-full \
2513
skopeo \
2614
tmux \
27-
trivy \
2815
vim \
2916
&& \
3017
apt-get clean
18+
COPY requirements.txt /tmp/requirements.txt
19+
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
20+
python3 -m pip install --no-cache-dir -r /tmp/requirements.txt
3121
USER vscode

.devcontainer/devcontainer.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,31 @@
55
},
66
"features": {
77
"ghcr.io/devcontainers/features/github-cli:1": {},
8-
"ghcr.io/devcontainers/features/sshd:1": {}
8+
"ghcr.io/devcontainers/features/sshd:1": {},
9+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
910
},
1011
"customizations": {
1112
"vscode": {
1213
"extensions": [
14+
//Python support
15+
"ms-python.python",
16+
//Python test explorer
17+
"littlefoxteam.vscode-python-test-adapter",
18+
//PEP Pyton formatter
19+
"ms-python.black-formatter",
20+
//Python debugger
21+
"ms-python.debugpy",
22+
//Github Action helper
1323
"github.vscode-github-actions",
24+
//Github Copilot
1425
"GitHub.copilot",
26+
//Github Copilot chat
1527
"GitHub.copilot-chat",
28+
//Github Pull Request
1629
"GitHub.vscode-pull-request-github",
17-
"ms-vscode-remote.remote-containers",
30+
//Git history
1831
"donjayamanne.githistory",
32+
//Git blame
1933
"solomonkinard.git-blame"
2034
],
2135
"settings": {
@@ -30,5 +44,5 @@
3044
}
3145
},
3246
"remoteUser": "vscode",
33-
"postCreateCommand": ".devcontainer/setup.sh"
47+
"postCreateCommand": "bash .devcontainer/setup.sh"
3448
}

.devcontainer/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
requests==2.31.0
2+
GitPython==3.1.43
3+
pyunpack==0.3
4+
patool==2.2.0

.devcontainer/setup.sh

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ fi
1919
echo "Updating localtime"
2020
sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime
2121

22+
# Install act
23+
gh extension install https://github.com/nektos/gh-act
24+
25+
# Install dependencies
26+
echo "Installing dependencies"
27+
python3 src/main.py install
2228
echo "End of setup"

.github/workflows/tests.yaml

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,54 @@ name: "action-test"
22
on:
33
push:
44
pull_request:
5-
workflow_dispatch:
6-
inputs:
7-
ref:
8-
description: "the git revision to checkout"
9-
required: false
10-
repo:
11-
description: "repository to scan"
12-
required: false
13-
input_path:
14-
description: "path to the repository"
15-
default: "."
16-
required: false
17-
output_path:
18-
description: "path to store the sbom"
19-
default: "."
20-
required: false
215

226
jobs:
23-
247
test-as-action:
258
runs-on: ubuntu-22.04
269
steps:
27-
2810
- name: Checkout
2911
uses: actions/checkout@v4
3012
with:
3113
path: ./
14+
fetch-depth: 0
15+
fetch-tags: true
3216

33-
- name: Install syft
17+
- name: Download artifact
3418
shell: bash
35-
run: |
36-
export DEBIAN_FRONTEND=noninteractive && \
37-
curl -O -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh && \
38-
sudo sh install.sh -b /usr/local/bin
19+
run: curl -o /tmp/Core-15.0.iso https://distro.ibiblio.org/tinycorelinux/15.x/x86/release/Core-15.0.iso
20+
21+
- name: Scan repo
22+
uses: ./
23+
with:
24+
target: ./
25+
output-dir: "/tmp/test/sbom"
26+
syft-version: "1.1.0"
27+
vuln-report: True
3928

40-
- name: Run syft
29+
- name: Scan directory
4130
uses: ./
4231
with:
43-
repo: sbom-test
44-
input_path: ./tests
45-
output_path: .
46-
generate_vulnerability_report: "true"
32+
target: /etc
33+
output-dir: "/tmp/test/sbom"
34+
name: "ghactionetc"
35+
36+
- name: Scan iso
37+
uses: ./
38+
with:
39+
target: /tmp/Core-15.0.iso
40+
output-dir: "/tmp/test/sbom"
41+
version: "15.0"
42+
name: "tinycorelinux"
43+
vuln-report: False
4744

4845
- name: Print the content of generated sbom file
46+
shell: bash
4947
run: |
50-
for sbom in repo_*.json; do
48+
for sbom in /tmp/test/sbom/*.json; do
5149
echo "Content of $sbom"
5250
cat $sbom
5351
done
54-
for sbom in repo_*.html; do
52+
for sbom in /tmp/test/sbom/reports/*.html; do
5553
echo "Content of vulnerability result for SBOM: $sbom"
5654
cat $sbom
5755
done

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ dist/
6666
downloads/
6767
eggs/
6868
.eggs/
69-
lib/
70-
lib64/
7169
parts/
7270
sdist/
7371
var/
@@ -223,11 +221,6 @@ pyrightconfig.json
223221

224222
### VisualStudioCode ###
225223
.vscode/*
226-
!.vscode/settings.json
227-
!.vscode/tasks.json
228-
!.vscode/launch.json
229-
!.vscode/extensions.json
230-
!.vscode/*.code-snippets
231224

232225
# Local History for Visual Studio Code
233226
.history/

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Contributing
2+
3+
Contributions are welcome! Please follow the guidelines below.
4+
5+
## Codespaces
6+
7+
This project is configured to work with GitHub Codespaces. To open the project in a Codespace, click the button below:
8+
9+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/scality/sbom)
10+
11+
## Run the action locally
12+
13+
`act` can be used to run the GitHub Actions workflow locally.
14+
It has been installed through the `gh` extension.
15+
To run the workflow locally, execute the following command:
16+
17+
```bash
18+
gh act push --rm --workflows=.github/workflows/tests.yaml -P ubuntu-22.04=ghcr.io/catthehacker/ubuntu:act-22.04
19+
```
20+
21+
For more information on how to use `act`, please refer to the [official documentation] or run `gh act --help`.
22+
23+
[official documentation]: https://nektosact.com/introduction.html

0 commit comments

Comments
 (0)