Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Create Initial Image #1

Merged
merged 35 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
742c01a
🚧 Initial push - to be squashed later
Gary-H9 Mar 5, 2024
b0d9d9c
Update Dockerfile
Mar 5, 2024
e1c76c0
Update README
Mar 5, 2024
a2c4d7c
Fix some linting issues
Mar 5, 2024
4c08213
Fix some linting issues
Mar 5, 2024
a521b1c
Added devcontainer
Mar 6, 2024
c793927
🚧 WIP
Gary-H9 Mar 6, 2024
eeec13e
🚧 WIP - Convert bash to python
Gary-H9 Mar 7, 2024
1251abe
🚨 Linting
Gary-H9 Mar 11, 2024
03ec621
🚨 Linting
Gary-H9 Mar 11, 2024
f906343
🚨 Linting
Gary-H9 Mar 11, 2024
d5cec04
🚨 Linting
Gary-H9 Mar 11, 2024
5e17263
Pin image with SHA
Mar 11, 2024
a1db49a
python black
Mar 11, 2024
3104e75
Add pylint
Mar 11, 2024
2b0715e
newline
Mar 11, 2024
f73c463
make files executable
Mar 11, 2024
641fd17
Add autopep8
Mar 11, 2024
43b0803
Exclude devcontainer from editorconfig EOF check
Mar 11, 2024
b2726db
Add Python feature
Mar 11, 2024
71a0658
Update dev reqa
Mar 11, 2024
9dc7ef6
Remove unneeded var
Gary-H9 Mar 11, 2024
0e6179e
Added flake8 config
Mar 11, 2024
31db335
commit
Mar 11, 2024
d1d5021
Exception handling
Gary-H9 Mar 11, 2024
b52e87e
Update
Mar 11, 2024
6afccb8
Fix pyproject
Mar 11, 2024
98b166e
Black formatting
Gary-H9 Mar 11, 2024
311aaa6
Add daily update schedule for pip package ecosystem
Mar 11, 2024
edc39d7
Merge branch 'initial-build' of github.com:ministryofjustice/analytic…
Mar 11, 2024
06ae540
Added SNS WIP
Mar 11, 2024
00d6b8d
Update README
Mar 11, 2024
2e3bea3
Added AWS feature
Mar 11, 2024
e228285
Update references
Mar 12, 2024
a7f8e6d
Activate release workflow
Mar 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "2.10.1",
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:440bdb81cf8af43f3e922450d33db9775c1097340557a5b7b6fe705bc758c5ef",
"integrity": "sha256:440bdb81cf8af43f3e922450d33db9775c1097340557a5b7b6fe705bc758c5ef"
},
"ghcr.io/devcontainers/features/python:1": {
"version": "1.4.1",
"resolved": "ghcr.io/devcontainers/features/python@sha256:d7e393af2440444dddb3c275cf7f90c899a24f8e853e4d6315e1be3be7e1d49f",
"integrity": "sha256:d7e393af2440444dddb3c275cf7f90c899a24f8e853e4d6315e1be3be7e1d49f"
},
"ghcr.io/ministryofjustice/devcontainer-feature/aws:0": {
"version": "0.0.2",
"resolved": "ghcr.io/ministryofjustice/devcontainer-feature/aws@sha256:db720f840ce5015117b1b1e7649dc59b8ac6b34a8786f07ab727dd081140737f",
"integrity": "sha256:db720f840ce5015117b1b1e7649dc59b8ac6b34a8786f07ab727dd081140737f"
}
}
}
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "analytical-platform-ingestion-scan",
"image": "ghcr.io/ministryofjustice/devcontainer-base:latest",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.12",
"installTools": false
},
"ghcr.io/ministryofjustice/devcontainer-feature/aws:0": {}
},
"postCreateCommand": "bash .devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"EditorConfig.EditorConfig",
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"ms-python.python",
"ms-python.pylint",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.flake8",
"ms-python.autopep8"
]
}
}
}
7 changes: 7 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# Upgrade Pip
pip install --upgrade pip

# Install dependencies
pip install --requirement requirements-dev.txt
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.json]
indent_style = space
indent_size = 2

[{*.sh,bootstrap}]
indent_style = space
indent_size = 2

[{*.yml,*.yaml}]
indent_style = space
indent_size = 2

# This file is autogenerated
[.devcontainer/devcontainer-lock.json]
end_of_line = unset
insert_final_newline = unset
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length=120
4 changes: 1 addition & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Add a team or username to this file
# Example:
# * @ministryofjustice/operations-engineering
* @ministryofjustice/analytical-platform
23 changes: 3 additions & 20 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
---
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2

updates:
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "terraform"
directory: "/terraform"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "pip"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gomod"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
26 changes: 26 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Build and Test

on:
pull_request:
branches:
- main

permissions: {}

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Build and Test
id: build_and_test
shell: bash
run: |
bash scripts/build-and-test.sh
5 changes: 4 additions & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Dependency Review

on:
pull_request:
branches:
- main
types:
- edited
- opened
Expand All @@ -22,7 +24,8 @@ jobs:
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Dependency Review
- name: Dependency review
id: dependency_review
uses: actions/dependency-review-action@9129d7d40b8c12c1ed0f60400d00c92d437adcce # v4.1.3
with:
fail-on-severity: critical
55 changes: 55 additions & 0 deletions .github/workflows/release.yml.deactivated
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: Release

on:
push:
tags:
- "*"

permissions: {}

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install cosign
id: install_cosign
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4 # v3.4.0

- name: Log in to GitHub Container Registry
id: login_ghcr
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push
id: build_and_push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
push: true
tags: ghcr.io/ministryofjustice/analytical-platform-ingestion-scan:${{ github.ref_name }}

- name: Sign
id: sign
shell: bash
run: |
cosign sign --yes ghcr.io/ministryofjustice/analytical-platform-ingestion-scan@${{ steps.build_and_push.outputs.digest }}

- name: Verify
id: verify
run: |
cosign verify \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com \
--certificate-identity=https://github.com/ministryofjustice/analytical-platform-ingestion-scan/.github/workflows/release.yml@refs/tags/${{ github.ref_name }} \
ghcr.io/ministryofjustice/analytical-platform-ingestion-scan@${{ steps.build_and_push.outputs.digest }}
57 changes: 57 additions & 0 deletions .github/workflows/scan-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: Scan Image

on:
pull_request:
branches:
- main

permissions: {}

jobs:
scan-image:
name: Scan Image
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Build Image
id: build_image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
push: false
load: true
tags: ingestion-scan

- name: Scan Image
id: scan_image
uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0
with:
image-ref: ingestion-scan
exit-code: 1
format: sarif
output: trivy-results.sarif
severity: CRITICAL
limit-severities-for-sarif: true

- name: Scan Image (On SARIF Scan Failure)
if: failure() && steps.scan_image.outcome == 'failure'
id: scan_image_on_failure
uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d # v0.18.0
with:
image-ref: ingestion-scan
exit-code: 1
format: table
severity: CRITICAL

- name: Upload SARIF
if: always()
id: upload_sarif
uses: github/codeql-action/upload-sarif@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.2.7
with:
sarif_file: trivy-results.sarif
36 changes: 36 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Super-Linter

on:
pull_request:
branches:
- main
types:
- edited
- opened
- reopened
- synchronize

permissions: {}

jobs:
super-linter:
name: Super-Linter
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Run Super-Linter
id: super_linter
uses: super-linter/super-linter/slim@e0fc164bba85f4b58c6cd17ba1dfd435d01e8a06 # v6.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
PYTHON_PYLINT_CONFIG_FILE: pyproject.toml
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#checkov:skip=CKV_DOCKER_2: HEALTHCHECK not required - AWS Lambda does not support HEALTHCHECK
#checkov:skip=CKV_DOCKER_3: USER not required - A non-root user is used by AWS Lambda
FROM public.ecr.aws/lambda/python:3.12@sha256:1d922f123370801843aad18d0911759c55402af4d0dddb601181df4ed42b2ce2

LABEL org.opencontainers.image.vendor="Ministry of Justice" \
org.opencontainers.image.authors="Analytical Platform (analytical-platform@digital.justice.gov.uk)" \
org.opencontainers.image.title="Ingestion Scan" \
org.opencontainers.image.description="Ingestion scan image for Analytical Platform" \
org.opencontainers.image.url="https://github.com/ministryofjustice/analytical-platform"

RUN microdnf update \
&& microdnf install --assumeyes \
clamav-0.103.9-1.amzn2023.0.2.x86_64 \
clamav-update-0.103.9-1.amzn2023.0.2.x86_64 \
clamd-0.103.9-1.amzn2023.0.2.x86_64 \
tar-2:1.34-1.amzn2023.0.4.x86_64 \
&& microdnf clean all

COPY --chown=nobody:nobody --chmod=0755 src/var/task/ ${LAMBDA_TASK_ROOT}

RUN python -m pip install --no-cache-dir --upgrade pip==24.0 \
&& python -m pip install --no-cache-dir --requirement requirements.txt

CMD ["handler.handler"]
Loading
Loading