Skip to content

Commit bd2f669

Browse files
committed
chore: Accept new Cruft update.
1 parent 73cb421 commit bd2f669

File tree

10 files changed

+269
-22
lines changed

10 files changed

+269
-22
lines changed

.cruft.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "git@github.com:CybercentreCanada/assemblyline-service-template.git",
3-
"commit": "99becf8ed2990a4063a5bb1f8ce878824a5a1a7b",
3+
"commit": "fb7207484332b978cc409dfc9b9c672335a8cc71",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -16,7 +16,12 @@
1616
"org_name_full": "CybercentreCanada",
1717
"org_name_short": "cccs",
1818
"license": "mit",
19-
"_template": "git@github.com:CybercentreCanada/assemblyline-service-template.git"
19+
"_extensions": [
20+
"local_extensions.github_maintainer.Ext"
21+
],
22+
"_template": "git@github.com:CybercentreCanada/assemblyline-service-template.git",
23+
"_commit": "fb7207484332b978cc409dfc9b9c672335a8cc71",
24+
"_github_maintainer": "gdesmar"
2025
}
2126
},
2227
"directory": null

.devcontainer/devcontainer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
3+
{
4+
"name": "Existing Dockerfile",
5+
"build": {
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "..",
8+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9+
"dockerfile": "../Dockerfile"
10+
},
11+
"containerEnv": {
12+
"SHELL": "/bin/bash"
13+
},
14+
"postCreateCommand": "pip install -r tests/requirements.txt",
15+
"runArgs": [
16+
"--network=host"
17+
],
18+
"customizations": {
19+
"vscode": {
20+
"extensions": [
21+
"ms-python.python",
22+
"charliermarsh.ruff",
23+
"elagil.pre-commit-helper",
24+
"ms-python.isort"
25+
]
26+
}
27+
},
28+
"workspaceMount": "source=${localWorkspaceFolder},target=/opt/al_service,type=bind,consistency=cached",
29+
"workspaceFolder": "/opt/al_service",
30+
// Features to add to the dev container. More info: https://containers.dev/features.
31+
// "features": {},
32+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
33+
// "forwardPorts": [],
34+
// Configure tool-specific properties.
35+
// "customizations": {},
36+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
37+
// "remoteUser": "devcontainer"
38+
}

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## code changes will send PR to following user
2+
* @gdesmar

.github/workflows/cruft-update.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# /.github/workflows/cruft-update.yml
2+
name: Update repository with Cruft
3+
permissions:
4+
contents: write
5+
pull-requests: write
6+
on:
7+
schedule:
8+
- cron: "0 2 * * *" # Every day at 2am
9+
jobs:
10+
update:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
include:
16+
- add-paths: .
17+
body: Use this to merge the changes to this repository.
18+
branch: cruft/update
19+
commit-message: "chore: Accept new Cruft update."
20+
title: New updates detected with Cruft
21+
- add-paths: .cruft.json
22+
body: Use this to reject the changes in this repository.
23+
branch: cruft/reject
24+
commit-message: "chore: Reject new Cruft update."
25+
title: Reject new updates detected with Cruft
26+
steps:
27+
- uses: actions/checkout@v6
28+
29+
- uses: actions/setup-python@v6
30+
with:
31+
python-version: "3.10"
32+
33+
- name: Install Cruft
34+
run: pip3 install cruft
35+
36+
- name: Check if update is available
37+
continue-on-error: false
38+
id: check
39+
run: |
40+
CHANGES=0
41+
if [ -f .cruft.json ]; then
42+
if ! cruft check; then
43+
CHANGES=1
44+
fi
45+
else
46+
echo "No .cruft.json file"
47+
fi
48+
49+
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
50+
51+
- name: Run update if available
52+
if: steps.check.outputs.has_changes == '1'
53+
run: |
54+
git config --global user.email "cruftbot@cyber.gc.ca"
55+
git config --global user.name "CruftBot"
56+
57+
cruft update --skip-apply-ask --refresh-private-variables
58+
git restore --staged .
59+
60+
- name: Create pull request
61+
if: steps.check.outputs.has_changes == '1'
62+
uses: peter-evans/create-pull-request@v7
63+
with:
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
add-paths: ${{ matrix.add-paths }}
66+
commit-message: ${{ matrix.commit-message }}
67+
branch: ${{ matrix.branch }}
68+
delete-branch: true
69+
title: ${{ matrix.title }}
70+
body: |
71+
This is an autogenerated PR. ${{ matrix.body }}
72+
73+
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Cookiecutter repository.
74+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# /.github/workflows/immortal-workflows.yml
2+
name: Reset workflows timeout
3+
on:
4+
schedule:
5+
- cron: "0 1 1 * *" # Every first of the month at 1am
6+
jobs:
7+
immortal-workflows:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v6
11+
12+
- name: Use GitHub CLI
13+
env:
14+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
run: |
16+
echo "Checking and resetting workflows timeout for repository ${{ github.repository }}"
17+
18+
# Taken from https://github.com/PhrozenByte/gh-workflow-immortality/blob/main/gh-workflow-immortality.sh
19+
# Replacing gh_api function with direct gh api calls for simplicity
20+
21+
WORKFLOWS_ALIVE=()
22+
WORKFLOWS_DEAD=()
23+
WORKFLOWS_DISABLED=()
24+
25+
API_RESULT=$(gh api \
26+
-H "Accept: application/vnd.github+json" \
27+
-H "X-GitHub-Api-Version: 2022-11-28" \
28+
/repos/${{ github.repository }}/actions/workflows | jq '.workflows')
29+
30+
[ -n "$API_RESULT" ] || return 1
31+
32+
__RESULT_ALIVE="$(jq -r --arg STATE "active" '.[]|select(.state == $STATE).path' <<< "$API_RESULT")"
33+
__RESULT_ALIVE="$(sed -ne 's#^\.github/workflows/\(.*\)$#\1#p' <<< "$__RESULT_ALIVE")"
34+
[ -z "$__RESULT_ALIVE" ] || readarray -t WORKFLOWS_ALIVE <<< "$__RESULT_ALIVE"
35+
36+
__RESULT_DEAD="$(jq -r --arg STATE "disabled_inactivity" '.[]|select(.state == $STATE).path' <<< "$API_RESULT")"
37+
__RESULT_DEAD="$(sed -ne 's#^\.github/workflows/\(.*\)$#\1#p' <<< "$__RESULT_DEAD")"
38+
[ -z "$__RESULT_DEAD" ] || readarray -t WORKFLOWS_DEAD <<< "$__RESULT_DEAD"
39+
40+
__RESULT_DISABLED="$(jq -r --arg STATE "disabled_manually" '.[]|select(.state == $STATE).path' <<< "$API_RESULT")"
41+
__RESULT_DISABLED="$(sed -ne 's#^\.github/workflows/\(.*\)$#\1#p' <<< "$__RESULT_DISABLED")"
42+
[ -z "$__RESULT_DISABLED" ] || readarray -t WORKFLOWS_DISABLED <<< "$__RESULT_DISABLED"
43+
44+
echo "Found ${#WORKFLOWS_ALIVE[@]} active, ${#WORKFLOWS_DEAD[@]} dead, and ${#WORKFLOWS_DISABLED[@]} disabled workflows"
45+
46+
# enable still active workflows
47+
for WORKFLOW in "${WORKFLOWS_ALIVE[@]}"; do
48+
echo "- Enabling still active workflow: $WORKFLOW"
49+
if [ -z "$DRY_RUN" ]; then
50+
gh api \
51+
--method PUT \
52+
-H "Accept: application/vnd.github+json" \
53+
-H "X-GitHub-Api-Version: 2022-11-28" \
54+
/repos/${{ github.repository }}/actions/workflows/$WORKFLOW/enable \
55+
|| { EXIT_CODE=1; true; }
56+
fi
57+
done
58+
59+
# enable dead workflows
60+
for WORKFLOW in "${WORKFLOWS_DEAD[@]}"; do
61+
echo "- Enabling dead workflow: $WORKFLOW"
62+
if [ -z "$DRY_RUN" ]; then
63+
gh api \
64+
--method PUT \
65+
-H "Accept: application/vnd.github+json" \
66+
-H "X-GitHub-Api-Version: 2022-11-28" \
67+
/repos/${{ github.repository }}/actions/workflows/$WORKFLOW/enable \
68+
|| { EXIT_CODE=1; true; }
69+
fi
70+
done
71+
72+
# print disabled workflows
73+
for WORKFLOW in "${WORKFLOWS_DISABLED[@]}"; do
74+
echo "- Found disabled workflow: $WORKFLOW"
75+
done

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#repos:
2+
# - repo: https://github.com/astral-sh/ruff-pre-commit
3+
# # Ruff version.
4+
# rev: v0.9.9
5+
# hooks:
6+
# # Run the linter.
7+
# - id: ruff
8+
# args: [ --fix ]
9+
# # Run the formatter.
10+
# - id: ruff-format

.vscode/launch.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"version": "0.2.0",
66
"configurations": [
77
{
8-
"name": "RunServiceOnce",
9-
"type": "python",
8+
"name": "RunServiceOnce Batchdeobfuscator",
9+
"type": "debugpy",
1010
"request": "launch",
1111
"module": "assemblyline_v4_service.dev.run_service_once",
1212
"cwd": "${workspaceFolder}",
@@ -17,5 +17,28 @@
1717
],
1818
"justMyCode": false,
1919
},
20+
{
21+
"name": "[Service] Batchdeobfuscator - Privileged",
22+
"type": "debugpy",
23+
"request": "launch",
24+
"module": "assemblyline_v4_service.run_privileged_service",
25+
"env": {
26+
"SERVICE_MANIFEST_PATH": "service_manifest.yml",
27+
"PRIVILEGED": "true",
28+
"SERVICE_PATH": "batchdeobfuscator.batchdeobfuscator.Batchdeobfuscator",
29+
"TASKING_DIR": "/tmp/Batchdeobfuscator"
30+
},
31+
"console": "internalConsole",
32+
"cwd": "${workspaceFolder}",
33+
"justMyCode": false,
34+
},
35+
{
36+
"name": "Generate Sample Tests",
37+
"type": "debugpy",
38+
"request": "launch",
39+
"module": "tests.gentests",
40+
"cwd": "${workspaceFolder}",
41+
"justMyCode": false,
42+
},
2043
]
2144
}

.vscode/settings.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2+
"[python]": {
3+
"editor.defaultFormatter": "charliermarsh.ruff",
4+
"editor.rulers": [
5+
120
6+
],
7+
"editor.tabSize": 4,
8+
"editor.wordWrap": "wordWrapColumn",
9+
"editor.wordWrapColumn": 120
10+
},
211
"editor.codeActionsOnSave": {
312
"source.organizeImports": "explicit"
413
},
514
"editor.formatOnSave": true,
6-
"editor.rulers": [
7-
120
8-
],
9-
"editor.tabSize": 4,
10-
"editor.wordWrap": "wordWrapColumn",
11-
"editor.wordWrapColumn": 120,
1215
"files.insertFinalNewline": true,
1316
"files.trimFinalNewlines": true,
1417
"files.trimTrailingWhitespace": true,
1518
"isort.args": [
1619
"-l",
1720
"120",
18-
"--profile=black",
21+
"--profile=black"
1922
// "--src=${workspaceFolder}"
2023
],
21-
"[python]": {
22-
"editor.defaultFormatter": "ms-python.black-formatter"
23-
},
24-
"black-formatter.args": [
25-
"--line-length=120"
26-
],
27-
"flake8.args": [
28-
"--max-line-length=120",
29-
//Added the ignore of E203 for now : https://github.com/PyCQA/pycodestyle/issues/373
30-
"--ignore=E203,W503"
24+
"python.testing.pytestArgs": [
25+
"tests"
3126
],
27+
"python.testing.pytestEnabled": true,
28+
"ruff.configuration": "pyproject.toml",
29+
"ruff.lint.enable": true,
30+
"ruff.lint.preview": true,
31+
"flake8.enabled": false
3232
}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG branch=latest
22
FROM cccs/assemblyline-v4-service-base:$branch
33

44
# Python path to the service class from your service directory
5-
ENV SERVICE_PATH batchdeobfuscator.batchdeobfuscator.Batchdeobfuscator
5+
ENV SERVICE_PATH=batchdeobfuscator.batchdeobfuscator.Batchdeobfuscator
66

77
# Install apt dependencies
88
USER root

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
11
[tool.cruft]
22
skip = ["pkglist.txt", "README.md", "batchdeobfuscator", "tests"]
3+
4+
[tool.ruff]
5+
line-length = 120
6+
target-version = "py311"
7+
8+
[tool.ruff.format]
9+
docstring-code-format = true
10+
quote-style = "double"
11+
indent-style = "space"
12+
13+
[tool.ruff.lint]
14+
# Add the `line-too-long` rule to the enforced rule set. By default, Ruff omits rules that
15+
# overlap with the use of a formatter, like Black, but we can override this behavior by
16+
# explicitly adding the rule.
17+
extend-select = ["E501", "D", "D404", "DOC"]
18+
ignore = ["D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107"]
19+
preview = true
20+
21+
[tool.ruff.lint.pydocstyle]
22+
convention = "google"

0 commit comments

Comments
 (0)