Skip to content

Commit 1611135

Browse files
committed
feat(16-dependencies-scan): added dependency review
1 parent 0026f51 commit 1611135

File tree

4 files changed

+95
-8
lines changed

4 files changed

+95
-8
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ministryofjustice/dev-sec-ops
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# GitHub Actions workflow for automated dependency review on pull requests
2+
#
3+
# Purpose:
4+
# Analyzes dependencies in pull requests targeting the main branch to identify
5+
# potential security vulnerabilities, license issues, and supply chain risks
6+
#
7+
# Triggers:
8+
# - Pull requests targeting the 'main' branch
9+
#
10+
# Workflow Jobs:
11+
# 1. setup: Configures infrastructure and environment variables
12+
# - Outputs environment name and timezone for downstream jobs
13+
# - Runs on ubuntu-latest
14+
#
15+
# 2. dependencies: Performs dependency analysis
16+
# - Requires 'contents: read' and 'pull-requests: write' permissions
17+
# - Uses GitHub's dependency-review-action to scan dependency changes
18+
# - Posts review summary as a comment on the pull request
19+
# - Depends on successful completion of setup job
20+
#
21+
# Environment Variables:
22+
# - environment: Set to 'base' deployment environment
23+
# - timezone: Retrieved from repository variable TIMEZONE
24+
#
25+
# Security:
26+
# - Workflow runs with minimal permissions (permissions: {})
27+
# - Individual jobs request only necessary permissions
28+
# - Uses pinned action versions with SHA commits for security
29+
#
30+
# Dependencies:
31+
# - actions/checkout@v6.0.1 (SHA: 8e8c483db84b4bee98b60c0593521ed34d9990e8)
32+
# - actions/dependency-review-action@v4.8.3 (SHA: 774d14bf50b7a2e2460f9f49e25c52503ecab125)
33+
#
34+
35+
name: Dependencies review
36+
run-name: Evaluating dependencies on ${{ github.event.pull_request.number }} 🔎
37+
38+
on:
39+
pull_request:
40+
branches: ["main"]
41+
42+
permissions: {}
43+
44+
env:
45+
environment: base
46+
timezone: ${{ vars.TIMEZONE }}
47+
48+
jobs:
49+
# 1. Setup test infrastructure
50+
setup:
51+
name: Infrastructure 🔧
52+
runs-on: ubuntu-latest
53+
outputs:
54+
environment: ${{ env.environment }}
55+
timezone: ${{ env.timezone }}
56+
steps:
57+
- name: Environment 🧪
58+
run: echo "Environment set to ${{ env.environment }}"
59+
60+
- name: Timezone 🌐
61+
run: echo "Timezone set to ${{ env.timezone }}"
62+
63+
# 2. Execute dependencies review
64+
dependencies:
65+
permissions:
66+
contents: read
67+
pull-requests: write
68+
69+
name: Dependencies 🔎
70+
needs: setup
71+
environment:
72+
name: ${{ needs.setup.outputs.environment }}
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Repository
77+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
78+
79+
- name: Review
80+
uses: actions/dependency-review-action@774d14bf50b7a2e2460f9f49e25c52503ecab125 #v4.8.3
81+
with:
82+
comment-summary-in-pr: always

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 Ministry of Justice
3+
Copyright (c) 2025 Crown Copyright (Ministry of Justice)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
A lightweight, Docker-based security scanner that integrates seamlessly with Git workflows to prevent hardcoded secrets from being committed to your repository. Built for the Ministry of Justice, this tool leverages following CLI commands to detect sensitive information such as API keys, passwords, tokens, and other credentials.
1313

14-
* [GitLeaks](https://github.com/gitleaks/gitleaks)
14+
- [GitLeaks](https://github.com/gitleaks/gitleaks)
1515

1616
## ✨ Features
1717

@@ -34,11 +34,13 @@ A lightweight, Docker-based security scanner that integrates seamlessly with Git
3434
### Installation
3535

3636
1. **Install pre-commit** (if not already installed):
37+
3738
```bash
3839
pip install pre-commit
3940
```
4041

4142
2. **Add to your repository** by creating or updating `.pre-commit-config.yaml`:
43+
4244
```yaml
4345
repos:
4446
- repo: https://github.com/ministryofjustice/devsecops-hooks
@@ -48,11 +50,13 @@ A lightweight, Docker-based security scanner that integrates seamlessly with Git
4850
```
4951
5052
3. **Install the hook**:
53+
5154
```bash
5255
pre-commit install
5356
```
5457

5558
4. **Run manually** (optional):
59+
5660
```bash
5761
pre-commit run --all-files
5862
```
@@ -135,8 +139,8 @@ docker run --rm -v $(pwd):/src ghcr.io/ministryofjustice/pre-commit-hook:latest
135139

136140
### ✅ Success (No Secrets Detected)
137141

138-
```
139-
⚡️ MoJ scanner 1.0.0⚡️
142+
```bash
143+
⚡️ Ministry of Justice - Scanner 1.0.0⚡️
140144

141145
142146
│╲
@@ -151,7 +155,7 @@ docker run --rm -v $(pwd):/src ghcr.io/ministryofjustice/pre-commit-hook:latest
151155

152156
### ❌ Failure (Secrets Detected)
153157

154-
```
158+
```bash
155159
⚡️ MoJ scanner 1.0.0⚡️
156160

157161
@@ -195,7 +199,7 @@ docker run --rm -v $(pwd):/src devsecops-hooks:local
195199

196200
## 📝 Environment Variables
197201

198-
### Required for Installation
202+
### Build Arguments
199203

200204
- `GIT_LEAKS_VERSION` - GitLeaks version to install (e.g., `8.30.0`)
201205
- `GIT_LEAKS_SHA512` - SHA-512 checksum for downloaded archive
@@ -209,7 +213,7 @@ docker run --rm -v $(pwd):/src devsecops-hooks:local
209213

210214
This project is licensed under the MIT Licence - see the [LICENSE](LICENSE) file for details.
211215

212-
**Copyright © 2025 Ministry of Justice**
216+
Copyright © 2025 Crown Copyright (Ministry of Justice)
213217

214218
## 🔗 Links
215219

@@ -234,4 +238,4 @@ If you encounter any issues or have questions:
234238

235239
---
236240

237-
**Made with ❤️ by the Ministry of Justice**
241+
Made with ❤️ by the Ministry of Justice

0 commit comments

Comments
 (0)