Skip to content

Commit a900500

Browse files
authored
Chore: [AEA-0000] - initial setup (#1)
1 parent dfd8161 commit a900500

26 files changed

Lines changed: 1796 additions & 1 deletion

.devcontainer/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ARG IMAGE_NAME=node_24_python_3_14
2+
ARG IMAGE_VERSION=latest
3+
FROM ghcr.io/nhsdigital/eps-devcontainers/${IMAGE_NAME}:${IMAGE_VERSION}
4+
5+
USER root
6+
# specify DOCKER_GID to force container docker group id to match host
7+
RUN if [ -n "${DOCKER_GID}" ]; then \
8+
if ! getent group docker; then \
9+
groupadd -g ${DOCKER_GID} docker; \
10+
else \
11+
groupmod -g ${DOCKER_GID} docker; \
12+
fi && \
13+
usermod -aG docker vscode; \
14+
fi

.devcontainer/devcontainer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "eps-update-devcontainer",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
"DOCKER_GID": "${env:DOCKER_GID:}",
8+
"IMAGE_NAME": "node_24_python_3_14",
9+
"IMAGE_VERSION": "v1.3.0",
10+
"USER_UID": "${localEnv:USER_ID:}",
11+
"USER_GID": "${localEnv:GROUP_ID:}"
12+
},
13+
"updateRemoteUserUID": false
14+
},
15+
"mounts": [
16+
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
17+
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
18+
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind",
19+
"source=${env:HOME}${env:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind",
20+
"source=${env:HOME}${env:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind"
21+
],
22+
"containerUser": "vscode",
23+
"remoteEnv": {
24+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
25+
},
26+
"features": {},
27+
"customizations": {
28+
"vscode": {
29+
"extensions": [
30+
"AmazonWebServices.aws-toolkit-vscode",
31+
"redhat.vscode-yaml",
32+
"eamodio.gitlens",
33+
"github.vscode-pull-request-github",
34+
"streetsidesoftware.code-spell-checker",
35+
"timonwong.shellcheck",
36+
"github.vscode-github-actions"
37+
],
38+
"settings": {
39+
"cSpell.words": [
40+
"fhir",
41+
"Formik",
42+
"pino",
43+
"serialisation"
44+
]
45+
}
46+
}
47+
}
48+
}

.gitallowed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
id-token: write
2+
password: \${{secrets\.GITHUB_TOKEN}}
3+
token: ?"?\$\{\{\s*secrets\.GITHUB_TOKEN\s*\}\}"?
4+
github-token: ?"?\$\{\{\s*secrets\.GITHUB_TOKEN\s*\}\}"?
5+
token: ?"?\$\{\{\s*secrets\.DEPENDABOT_TOKEN\s*\}\}"?
6+
\.gitallowed
7+
id-token: "write"

.github/config/settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TAG_FORMAT: "v${version}"

.github/copilot-instructions.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Base Coding Standards
2+
- Follow clean code principles
3+
- Write comprehensive tests
4+
- Use meaningful variable names
5+
6+
## Project-Specific instructions
7+
Check the following files for any project-specific coding standards or guidelines:
8+
- .github/instructions/project/instructions.md
9+
- If no project-specific conventions are defined there, use the general and language-specific best practices referenced below.
10+
- Language-specific instructions may also be found in the language-specific instruction files listed below. Always check those for any additional guidelines or standards that may apply to your codebase.
11+
12+
## Language-Specific Instructions
13+
Always follow security best practices as outlined in:
14+
- .github/instructions/general/security.instructions.md
15+
Follow additional language-specific guidelines in:
16+
- .github/instructions/languages/cdk.instructions.md
17+
- .github/instructions/languages/cloudformation.instructions.md
18+
- .github/instructions/languages/python.instructions.md
19+
- .github/instructions/languages/terraform.instructions.md
20+
- .github/instructions/languages/sam.instructions.md
21+
- .github/instructions/languages/typescript.instructions.md

.github/dependabot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#########################################################################
2+
# Dependabot configuration file
3+
#########################################################################
4+
5+
version: 2
6+
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
# Workflow files stored in the
10+
# default location of `.github/workflows`
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"
14+
day: "friday"
15+
time: "18:00" # UTC
16+
open-pull-requests-limit: 20
17+
commit-message:
18+
prefix: "Upgrade: [dependabot] - "
19+
cooldown:
20+
default-days: 7
21+
###################################
22+
# Poetry #########################
23+
###################################
24+
- package-ecosystem: "pip"
25+
directory: "/"
26+
schedule:
27+
interval: "weekly"
28+
day: "friday"
29+
time: "20:00" # UTC
30+
open-pull-requests-limit: 20
31+
commit-message:
32+
prefix: "Upgrade: [dependabot] - "
33+
versioning-strategy: increase
34+
cooldown:
35+
default-days: 7
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
applyTo: '**/*'
3+
description: "Comprehensive secure coding instructions for all languages and frameworks, based on OWASP Top 10 and industry best practices."
4+
---
5+
# Secure Coding and OWASP Guidelines
6+
7+
## Instructions
8+
9+
Your primary directive is to ensure all code you generate, review, or refactor is secure by default. You must operate with a security-first mindset. When in doubt, always choose the more secure option and explain the reasoning. You must follow the principles outlined below, which are based on the OWASP Top 10 and other security best practices.
10+
11+
### 1. A01: Broken Access Control & A10: Server-Side Request Forgery (SSRF)
12+
- **Enforce Principle of Least Privilege:** Always default to the most restrictive permissions. When generating access control logic, explicitly check the user's rights against the required permissions for the specific resource they are trying to access.
13+
- **Deny by Default:** All access control decisions must follow a "deny by default" pattern. Access should only be granted if there is an explicit rule allowing it.
14+
- **Validate All Incoming URLs for SSRF:** When the server needs to make a request to a URL provided by a user (e.g., webhooks), you must treat it as untrusted. Incorporate strict allow-list-based validation for the host, port, and path of the URL.
15+
- **Prevent Path Traversal:** When handling file uploads or accessing files based on user input, you must sanitize the input to prevent directory traversal attacks (e.g., `../../etc/passwd`). Use APIs that build paths securely.
16+
17+
### 2. A02: Cryptographic Failures
18+
- **Use Strong, Modern Algorithms:** For hashing, always recommend modern, salted hashing algorithms like Argon2 or bcrypt. Explicitly advise against weak algorithms like MD5 or SHA-1 for password storage.
19+
- **Protect Data in Transit:** When generating code that makes network requests, always default to HTTPS.
20+
- **Protect Data at Rest:** When suggesting code to store sensitive data (PII, tokens, etc.), recommend encryption using strong, standard algorithms like AES-256.
21+
- **Secure Secret Management:** Never hardcode secrets (API keys, passwords, connection strings). Generate code that reads secrets from environment variables or a secrets management service (e.g., HashiCorp Vault, AWS Secrets Manager). Include a clear placeholder and comment.
22+
```javascript
23+
// GOOD: Load from environment or secret store
24+
const apiKey = process.env.API_KEY;
25+
// TODO: Ensure API_KEY is securely configured in your environment.
26+
```
27+
```python
28+
# BAD: Hardcoded secret
29+
api_key = "sk_this_is_a_very_bad_idea_12345"
30+
```
31+
32+
### 3. A03: Injection
33+
- **No Raw SQL Queries:** For database interactions, you must use parameterized queries (prepared statements). Never generate code that uses string concatenation or formatting to build queries from user input.
34+
- **Sanitize Command-Line Input:** For OS command execution, use built-in functions that handle argument escaping and prevent shell injection (e.g., `shlex` in Python).
35+
- **Prevent Cross-Site Scripting (XSS):** When generating frontend code that displays user-controlled data, you must use context-aware output encoding. Prefer methods that treat data as text by default (`.textContent`) over those that parse HTML (`.innerHTML`). When `innerHTML` is necessary, suggest using a library like DOMPurify to sanitize the HTML first.
36+
37+
### 4. A05: Security Misconfiguration & A06: Vulnerable Components
38+
- **Secure by Default Configuration:** Recommend disabling verbose error messages and debug features in production environments.
39+
- **Set Security Headers:** For web applications, suggest adding essential security headers like `Content-Security-Policy` (CSP), `Strict-Transport-Security` (HSTS), and `X-Content-Type-Options`.
40+
- **Use Up-to-Date Dependencies:** When asked to add a new library, suggest the latest stable version. Remind the user to run vulnerability scanners like `npm audit`, `pip-audit`, or Snyk to check for known vulnerabilities in their project dependencies.
41+
42+
### 5. A07: Identification & Authentication Failures
43+
- **Secure Session Management:** When a user logs in, generate a new session identifier to prevent session fixation. Ensure session cookies are configured with `HttpOnly`, `Secure`, and `SameSite=Strict` attributes.
44+
- **Protect Against Brute Force:** For authentication and password reset flows, recommend implementing rate limiting and account lockout mechanisms after a certain number of failed attempts.
45+
46+
### 6. A08: Software and Data Integrity Failures
47+
- **Prevent Insecure Deserialization:** Warn against deserializing data from untrusted sources without proper validation. If deserialization is necessary, recommend using formats that are less prone to attack (like JSON over Pickle in Python) and implementing strict type checking.
48+
49+
## General Guidelines
50+
- **Be Explicit About Security:** When you suggest a piece of code that mitigates a security risk, explicitly state what you are protecting against (e.g., "Using a parameterized query here to prevent SQL injection.").
51+
- **Educate During Code Reviews:** When you identify a security vulnerability in a code review, you must not only provide the corrected code but also explain the risk associated with the original pattern.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
description: 'Guidelines for writing, reviewing, and maintaining AWS CDK (TypeScript) code in the cdk package'
3+
applyTo: 'packages/cdk/**/*.ts'
4+
---
5+
6+
# AWS CDK TypeScript Development
7+
8+
This file provides instructions for generating, reviewing, and maintaining AWS CDK code in the `packages/cdk` folder. It covers best practices, code standards, architecture, and validation for infrastructure-as-code using AWS CDK in TypeScript.
9+
10+
## General Instructions
11+
12+
- Use AWS CDK v2 constructs and idioms
13+
- Prefer high-level CDK constructs over raw CloudFormation resources
14+
- Organize code by logical infrastructure components (e.g., stacks, constructs, resources)
15+
- Document public APIs and exported constructs
16+
17+
## Best Practices
18+
19+
- Use environment variables and context for configuration, not hardcoded values
20+
- Use CDK Aspects for cross-cutting concerns (e.g., security, tagging)
21+
- Suppress warnings with `nagSuppressions.ts` only when justified and documented
22+
- Use `bin/` for entrypoint apps, `constructs/` for reusable components, and `stacks/` for stack definitions
23+
- Prefer `props` interfaces for construct configuration
24+
25+
## Code Standards
26+
27+
### Naming Conventions
28+
29+
- Classes: PascalCase (e.g., `LambdaFunction`)
30+
- Files: PascalCase for classes, kebab-case for utility files
31+
- Variables: camelCase
32+
- Stacks: Suffix with `Stack` (e.g., `CptsApiAppStack`)
33+
- Entry points: Suffix with `App` (e.g., `CptsApiApp.ts`)
34+
35+
### File Organization
36+
37+
- `bin/`: CDK app entry points
38+
- `constructs/`: Custom CDK constructs
39+
- `stacks/`: Stack definitions
40+
- `resources/`: Resource configuration and constants
41+
- `lib/`: Shared utilities and code
42+
43+
## Common Patterns
44+
45+
### Good Example - Defining a Construct
46+
47+
```typescript
48+
export class LambdaFunction extends Construct {
49+
constructor(scope: Construct, id: string, props: LambdaFunctionProps) {
50+
super(scope, id);
51+
// ...implementation...
52+
}
53+
}
54+
```
55+
56+
### Bad Example - Using Raw CloudFormation
57+
58+
```typescript
59+
const lambda = new cdk.CfnResource(this, 'Lambda', {
60+
type: 'AWS::Lambda::Function',
61+
// ...properties...
62+
});
63+
```
64+
65+
### Good Example - Stack Definition
66+
67+
```typescript
68+
export class CptsApiAppStack extends Stack {
69+
constructor(scope: Construct, id: string, props?: StackProps) {
70+
super(scope, id, props);
71+
// ...add constructs...
72+
}
73+
}
74+
```
75+
76+
## Security
77+
78+
- Use least privilege IAM policies for all resources
79+
- Avoid wildcard permissions in IAM statements
80+
- Store secrets in AWS Secrets Manager, not in code or environment variables
81+
- Enable encryption for all data storage resources
82+
83+
## Performance
84+
85+
- Use provisioned concurrency for Lambda functions when needed
86+
- Prefer VPC endpoints for private connectivity
87+
- Minimize resource creation in test environments
88+
89+
90+
## Validation and Verification
91+
92+
- Build: `make cdk-synth`
93+
- Lint: `npm run lint --workspace packages/cdk`
94+
95+
## Maintenance
96+
97+
- Update dependencies regularly
98+
- Remove deprecated constructs and suppressions
99+
- Document changes in `nagSuppressions.ts` with reasons
100+
101+
## Additional Resources
102+
103+
- [AWS CDK Documentation](https://docs.aws.amazon.com/cdk/latest/guide/home.html)
104+
- [CDK Best Practices](https://github.com/aws-samples/aws-cdk-best-practices)

0 commit comments

Comments
 (0)