Skip to content

Commit 68087d5

Browse files
author
Yoan Moscatelli
committed
👷 add dependabot
1 parent 769825e commit 68087d5

4 files changed

Lines changed: 113 additions & 1 deletion

File tree

.github/dependabot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/.github/workflows"
5+
schedule:
6+
interval: "daily"
7+
reviewers:
8+
- "scality/metalk8s"
9+
10+
- package-ecosystem: "pip"
11+
directory: "./requirements.txt"
12+
schedule:
13+
interval: "daily"
14+
rebase-strategy: "auto"
15+
ignore:
16+
- dependency-name: "requests"
17+
versions: ["<2.25.1"]
18+
reviewers:
19+
- "scality/metalk8s"
20+
21+
- package-ecosystem: "npm"
22+
directory: "/tests"
23+
schedule:
24+
interval: "daily"
25+
labels: [test]
26+
ignore:
27+
- dependency-name: "*"
28+
29+
- package-ecosystem: "github-actions"
30+
directory: "/tests"
31+
schedule:
32+
interval: "daily"
33+
labels: [test]
34+
ignore:
35+
- dependency-name: "*"

.github/scripts/update_scanners.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import re
2+
import requests
3+
4+
# Define the scanners and their GitHub repositories
5+
scanners = {
6+
"syft": "anchore/syft",
7+
"grype": "anchore/grype",
8+
"trivy": "aquasecurity/trivy"
9+
}
10+
11+
def get_latest_release(repo):
12+
url = f"https://api.github.com/repos/{repo}/releases/latest"
13+
response = requests.get(url)
14+
response.raise_for_status()
15+
return response.json()["tag_name"].lstrip("v")
16+
17+
def update_versions(file_path):
18+
with open(file_path, "r") as file:
19+
content = file.read()
20+
21+
for scanner, repo in scanners.items():
22+
latest_version = get_latest_release(repo)
23+
content = re.sub(
24+
f'("{scanner}": ")([^"]+)',
25+
lambda match: f'{match.group(1)}{latest_version}',
26+
content
27+
)
28+
29+
with open(file_path, "w") as file:
30+
file.write(content)
31+
32+
if __name__ == "__main__":
33+
update_versions("src/lib/install.py")
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Update Scanners
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Runs daily at midnight
6+
workflow_dispatch:
7+
8+
jobs:
9+
update-scanners:
10+
runs-on: ubuntu-24.04
11+
steps:
12+
13+
- name: Create github token
14+
uses: actions/create-github-app-token@v1
15+
id: app-token
16+
with:
17+
app-id: ${{ vars.ACTIONS_APP_ID }}
18+
private-key: ${{ secrets.ACTIONS_APP_PRIVATE_KEY }}
19+
owner: ${{ github.repository_owner }}
20+
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
token: ${{ steps.app-token.outputs.token }}
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: 3.12
30+
31+
- name: Install dependencies
32+
run: pip install requests
33+
34+
- name: Update scanner versions
35+
run: python .github/scripts/update_scanners.py
36+
37+
- name: Create Pull Request
38+
uses: peter-evans/create-pull-request@v7
39+
id: pr
40+
with:
41+
title: Dependency update
42+
branch: feature/deps-update
43+
commit-message: ":arrow_up: Update scanner versions"
44+
token: ${{ steps.app-token.outputs.token }}

src/lib/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pyunpack import Archive
88

99
# Define the scanners and their versions
10-
scanners = {"syft": "1.8.0", "grype": "0.79.1", "trivy": "0.53.0"}
10+
scanners = {"syft": "1.20.0", "grype": "0.89.1", "trivy": "0.60.0"}
1111

1212
# Define the base URLs for the scanners
1313
ANCHORE_BASE_URL = (

0 commit comments

Comments
 (0)