You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/continuous_integration.md
+22-7Lines changed: 22 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,5 @@
1
1
# Continuous integration
2
2
3
-
NOTE: This guidance only applies to repositories and projects which are public on GitHub and can therefore take advantage of several free integrations. We intend to expand upon this guide in the future to cover the rest of our ecosystem.
4
-
5
3
> Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
@@ -28,10 +26,27 @@ There are lots of other tools which can integrate with GitHub, especially if you
28
26
29
27
These tools check the security of your project. This can include reporting vulnerabilities in your dependencies, or doing static analysis on your code.
30
28
31
-
- Use [Dependabot](https://docs.github.com/en/code-security/tutorials/secure-your-dependencies/dependabot-quickstart-guide) and/or [npm audit](https://docs.npmjs.com/cli/v9/commands/npm-audit) for Node.js projects
32
-
- Use [Hakiri](https://hakiri.io/) for Ruby projects
29
+
#### Dependabot
30
+
31
+
Enable [Dependabot](https://docs.github.com/en/code-security/dependabot) in each repository to automatically raise pull requests when vulnerable or outdated dependencies are detected.
32
+
33
+
Dependabot depends on the [dependency graph](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph) being enabled.
34
+
35
+
> Dependency graph will shortly be automatically enabled for all repositories by default.
36
+
37
+
Grouped Dependabot updates are recommended to reduce pull request noise.
38
+
39
+
#### Dependency review action
40
+
41
+
Add the [dependency review action](https://github.com/actions/dependency-review-action) to your pull request workflows. It checks whether a PR is introducing any packages with known vulnerabilities and fails the check if so, preventing vulnerable dependencies from being merged.
42
+
43
+
The review won't catch vulnerabilities in existing dependencies, but it will help prevent new ones from being added.
44
+
45
+
See the [security standards](../standards/security_standards.md) for more details and an example workflow.
46
+
47
+
#### GitHub Security tab
33
48
34
-
These tools are free to use for open source GitHub repositories.
49
+
Regularly review the **Security** tab in your GitHub repository. It provides a continuously-updated view of Dependabot alerts, code scanning results, and secret scanning alerts without needing to trigger a build.
35
50
36
51
### Maintainability and test coverage
37
52
@@ -45,6 +60,6 @@ It will then include your test coverage in its assessment of your code.
45
60
46
61
SonarQube Cloud is free to use for open source GitHub repositories.
47
62
48
-
##CI with Jenkins
63
+
### Significant changes
49
64
50
-
We use Jenkins for our internal build servers.
65
+
GitHub Advanced Security integration added 1 May 2026.
Copy file name to clipboardExpand all lines: docs/standards/node_standards.md
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
### General
4
4
- Node.js code is JavaScript code and should follow the [JavaScript standards](javascript_standards.md).
5
-
- Don't use TypeScript.
5
+
- Don't use TypeScript without an approved exemption.
6
6
- Session state should not be stored on the node app server. Don't tie a session to a particular node server instance. Use a distributed cache or document storage database and not something like express-session.
7
7
- Avoid blocking the [main event loop and the worker pool](https://nodejs.org/en/docs/guides/dont-block-the-event-loop/). In short "you shouldn't do too much work for any client in any single callback or task." and consider passing CPU intensive tasks off to another service.
8
8
- Prefer await over callbacks and avoid nested callbacks. This is easily done in [Node 8 and above](https://nodejs.org/api/util.html#util_util_promisify_original).
@@ -16,12 +16,40 @@
16
16
- Don't progress beyond Active LTS versions.
17
17
18
18
### Package Management
19
-
- Use NPM.
19
+
- Use npm.
20
20
- Use a package.json and package-lock.json for repeatable builds.
21
+
- Use `npm ci` instead of `npm install` in automated production builds to ensure the exact versions in `package-lock.json` are installed. It will also fail if the `package-lock.json` and `package.json` are out of sync, which can help catch mistakes.
21
22
- Use an automated checker such as Dependabot or npm audit to ensure that your dependencies are up to date with the
22
23
latest patches.
23
24
- Separate dependencies and dev dependencies.
24
25
- Update your version number inline with the [semantic versioning standard](https://semver.org/).
26
+
- Vet third-party packages before adding them as dependencies by following this [guide](../guides/choosing_packages.md).
27
+
28
+
#### .npmrc security settings
29
+
30
+
Create an `.npmrc` file at the root of each repository with the following settings:
31
+
32
+
```ini
33
+
save-exact=true
34
+
ignore-scripts=true
35
+
min-release-age=7
36
+
```
37
+
38
+
| Setting | Purpose |
39
+
|---|---|
40
+
|`save-exact=true`| Saves exact dependency versions rather than version ranges. Prevents version-range drift from silently pulling in a later, potentially vulnerable release. |
41
+
|`ignore-scripts=true`| Prevents npm from running lifecycle scripts such as `preinstall` and `postinstall` during package installation. This blocks a common vector for arbitrary code execution from malicious or compromised packages. Note: some packages that compile native bindings require lifecycle scripts to function. If any packages genuinely need it, then `--ignore-scripts=false` can be passed to the relevant `npm install` command. |
42
+
|`min-release-age=7`| Refuses to install packages published fewer than 7 days ago. This provides a window to detect package takeover or typosquatting attacks before they reach your codebase. Studies have shown that most malicious packages are detected within this timeframe. |
43
+
44
+
To apply these settings globally across all projects on your machine, either run:
45
+
46
+
```sh
47
+
npm config set save-exact=true
48
+
npm config set ignore-scripts=true
49
+
npm config set min-release-age=7
50
+
```
51
+
52
+
or add the three lines directly to your global npm configuration file at `~/.npmrc`.
25
53
26
54
### Server framework
27
55
- Our standard framework is [Hapi](https://hapijs.com/).
@@ -43,3 +71,4 @@ This standard was formally adopted on 8 January 2020.
43
71
### Significant changes
44
72
45
73
Clarification on preference between CommonJS and ESM added 29 July 2024.
Copy file name to clipboardExpand all lines: docs/standards/security_standards.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,39 @@ The way we build software and systems is rapidly evolving, becoming more and mor
9
9
Use the [OWASP Secure coding practices - quick reference guide](https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide) for details of the standards to apply.
10
10
11
11
**Important note.** We are using version 2
12
+
13
+
## GitHub Advanced Security
14
+
15
+
Defra has GitHub Advanced Security enabled across its organisation. Teams should maximise use of these built-in features rather than relying on third-party tools.
16
+
17
+
### Dependency graph
18
+
19
+
Ensure the [dependency graph](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph) is enabled in every repository. It is the foundation for Dependabot alerts and the dependency review action.
20
+
21
+
### Dependabot
22
+
23
+
Enable [Dependabot](https://docs.github.com/en/code-security/dependabot) to automatically raise pull requests when vulnerable or outdated dependencies are detected. Grouped updates are recommended to reduce noise — see [grouping Dependabot version updates](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#groups) for configuration details.
24
+
25
+
### Dependency review action
26
+
27
+
Add the [GitHub dependency review action](https://github.com/actions/dependency-review-action) to your pull request workflow. It compares the dependencies introduced by a PR against the GitHub Advisory Database and fails the check if any known-vulnerable packages are being added, preventing vulnerabilities from being merged rather than detecting them after the fact.
28
+
29
+
An example workflow can be found in the [fcp-audit repository](https://github.com/DEFRA/fcp-audit/blob/309fc8ed7022ed981ee620d97bd455799a704cf0/.github/workflows/).
30
+
31
+
### GitHub Security tab
32
+
33
+
Regularly review the **Security** tab in your repository. It provides a continuously-updated view of:
34
+
35
+
- Dependabot alerts for vulnerable dependencies already in the repo
36
+
- Code scanning alerts from static analysis
37
+
- Secret scanning alerts
38
+
39
+
This means you do not need to wait for a build to run to discover a vulnerability, issues are surfaced as soon as they are detected.
40
+
41
+
### Snyk
42
+
43
+
Snyk has been assessed alongside GitHub Advanced Security. As GitHub Advanced Security provides largely equivalent capability and is already available to all Defra teams, teams should look to maximise usage of GitHub Advanced Security rather than relying on Snyk.
44
+
45
+
### Significant changes
46
+
47
+
GitHub Advanced Security integration added 1 May 2026.
0 commit comments