forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DefectDojo#9260 from DefectDojo/master-into-bugfix…
…/2.30.0-2.31.0-dev Release: Merge back 2.30.0 into bugfix from: master-into-bugfix/2.30.0-2.31.0-dev
- Loading branch information
Showing
102 changed files
with
9,763 additions
and
745 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,62 @@ | ||
--- | ||
docs: | ||
- docs/**/* | ||
- readme-docs/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- docs/**/* | ||
- readme-docs/**/* | ||
|
||
docker: | ||
- docker/**/* | ||
- docker** | ||
- Docker* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- docker/**/* | ||
- docker** | ||
- Docker* | ||
|
||
helm: | ||
- helm/defectdojo/* | ||
- helm/defectdojo/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- helm/defectdojo/* | ||
- helm/defectdojo/**/* | ||
|
||
"New Migration": | ||
- dojo/db_migrations/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- dojo/db_migrations/* | ||
|
||
unittests: | ||
- unittests/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- unittests/**/* | ||
|
||
integration_tests: | ||
- tests/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- tests/**/* | ||
|
||
settings_changes: | ||
- dojo/settings/settings.dist.py | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- dojo/settings/settings.dist.py | ||
|
||
apiv2: | ||
- dojo/api_v2/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- dojo/api_v2/**/* | ||
|
||
ui: | ||
- dojo/static/**/* | ||
- dojo/templates/**/* | ||
- dojo/templatetags/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- dojo/static/**/* | ||
- dojo/templates/**/* | ||
- dojo/templatetags/**/* | ||
|
||
parser: | ||
- dojo/tools/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- dojo/tools/**/* | ||
|
||
localization: | ||
- dojo/locale/* | ||
- dojo/locale/**/* | ||
- changed-files: | ||
- any-glob-to-any-file: | ||
- dojo/locale/* | ||
- dojo/locale/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Fetch OpenAPI Specifications | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
oas_fetch: | ||
name: Fetch OpenAPI Specifications | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
file-type: [yaml, json] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# load docker images from build jobs | ||
- name: Load images from artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Load docker images | ||
run: |- | ||
docker load -i nginx/nginx-alpine_img | ||
docker load -i django/django-alpine_img | ||
docker images | ||
- name: Start Dojo | ||
run: docker-compose --profile postgres-redis --env-file ./docker/environments/postgres-redis.env up --no-deps -d postgres nginx uwsgi | ||
env: | ||
DJANGO_VERSION: alpine | ||
NGINX_VERSION: alpine | ||
|
||
- name: Download OpenAPI Specifications | ||
run: |- | ||
wget 'http://localhost:8080/api/v2/oa3/schema/?format=${{ matrix.file-type }}' -O oas.${{ matrix.file-type }} --tries=10 --retry-on-http-error=502 | ||
- name: Logs | ||
if: always() | ||
run: docker-compose --profile postgres-redis --env-file ./docker/environments/postgres-redis.env logs --tail="2500" | ||
|
||
- name: Shutdown | ||
if: always() | ||
run: docker-compose --profile postgres-redis --env-file ./docker/environments/postgres-redis.env down | ||
|
||
- name: Upload oas.${{ matrix.file-type }} as artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: oas-${{ matrix.file-type }} | ||
path: oas.${{ matrix.file-type }} | ||
retention-days: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,50 @@ on: | |
# branches to consider in the event; optional, defaults to all | ||
branches: | ||
- master | ||
- dev | ||
|
||
jobs: | ||
build-docker-containers: | ||
uses: ./.github/workflows/build-docker-images-for-testing.yml | ||
secrets: inherit | ||
|
||
oas-fetch: | ||
needs: build-docker-containers | ||
uses: ./.github/workflows/fetch-oas.yml | ||
secrets: inherit | ||
|
||
update_release_draft: | ||
needs: oas-fetch | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: release-drafter/[email protected] | ||
- name: Load OAS files from artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: release-drafter/[email protected] | ||
with: | ||
version: ${{github.event.inputs.version}} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload Release Asset - OpenAPI Specification - YAML | ||
id: upload-release-asset-yaml | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./oas-yaml/oas.yaml | ||
asset_name: oas.yaml | ||
asset_content_type: application/vnd.oai.openapi | ||
|
||
- name: Upload Release Asset - OpenAPI Specification - JSON | ||
id: upload-release-asset-json | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./oas-json/oas.json | ||
asset_name: oas.json | ||
asset_content_type: application/json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
name: Shellcheck | ||
on: | ||
pull_request: | ||
env: | ||
SHELLCHECK_REPO: 'koalaman/shellcheck' | ||
SHELLCHECK_VERSION: 'v0.9.0' | ||
SHELLCHECK_SHA: '038fd81de6b7e20cc651571362683853670cdc71' | ||
jobs: | ||
shellcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Grab shellcheck | ||
run: | | ||
set -e | ||
SHELLCHECK_TARBALL_URL="https://github.com/${SHELLCHECK_REPO}/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | ||
SHELLCHECK_TARBALL_LOC="shellcheck.tar.xz" | ||
curl -L "${SHELLCHECK_TARBALL_URL}" -o "${SHELLCHECK_TARBALL_LOC}" | ||
tarball_sha=$(shasum ${SHELLCHECK_TARBALL_LOC} | awk '{print $1}') | ||
if [ "${tarball_sha}" != "${SHELLCHECK_SHA}" ]; then | ||
echo "Got invalid SHA for shellcheck: ${tarball_sha}" | ||
exit 1 | ||
fi | ||
tar -xvf "${SHELLCHECK_TARBALL_LOC}" | ||
cd "shellcheck-${SHELLCHECK_VERSION}" || exit 1 | ||
mv shellcheck "${GITHUB_WORKSPACE}/shellcheck" | ||
- name: Run shellcheck | ||
shell: bash | ||
run: | | ||
set -o pipefail | ||
# Make sure we already put the proper shellcheck binary in place | ||
if [ ! -f "./shellcheck" ]; then | ||
echo "shellcheck not found" | ||
exit 1 | ||
fi | ||
# Make sure we know what to compare the PR's changes against | ||
if [ -z "${GITHUB_BASE_REF}" ]; then | ||
echo "No base reference supplied" | ||
exit 1 | ||
fi | ||
num_findings=0 | ||
# Execute shellcheck and add errors based on the output | ||
run_shellcheck() { | ||
local modified_shell_script="${1}" | ||
local findings_file="findings.txt" | ||
# Remove leftover findings file from previous iterations | ||
if [ -f "${findings_file}" ]; then | ||
rm "${findings_file}" | ||
fi | ||
echo "Running shellcheck against ${modified_shell_script}..." | ||
# If shellcheck reported no errors (exited with 0 status code), return | ||
if ./shellcheck -f json -S warning "${modified_shell_script}" | jq -c '.[]' > "${findings_file}"; then | ||
return 0 | ||
fi | ||
# Walk each of the individual findings | ||
while IFS= read -r finding; do | ||
num_findings=$((num_findings+1)) | ||
line=$(echo "${finding}" | jq '.line') | ||
end_line=$(echo "${finding}" | jq '.endLine') | ||
column=$(echo "${finding}" | jq '.column') | ||
end_column=$(echo "${finding}" | jq '.endColumn') | ||
code=$(echo "${finding}" | jq '.code') | ||
title="SC${code}" | ||
message="$(echo "${finding}" | jq -r '.message') See https://github.com/koalaman/shellcheck/wiki/${title}" | ||
echo "Line: ${line}" | ||
echo "End line: ${end_line}" | ||
echo "Column: ${column}" | ||
echo "End column: ${end_column}" | ||
echo "Title: ${title}" | ||
echo "Message: ${message}" | ||
# Raise an error with the file/line/etc | ||
echo "::error file=${modified_shell_script},line=${line},endLine=${end_line},column=${column},endColumn=${end_column},title=${title}::${message}" | ||
done < ${findings_file} | ||
} | ||
# Find the shell scripts that were created or modified by this PR | ||
find_modified_shell_scripts() { | ||
shell_scripts="shell_scripts.txt" | ||
modified_files="modified_files.txt" | ||
modified_shell_scripts="modified_shell_scripts.txt" | ||
find . -name "*.sh" -or -name "*.bash" | sed 's#^\./##' > "${shell_scripts}" | ||
git diff --name-only "origin/${GITHUB_BASE_REF}" HEAD > "${modified_files}" | ||
if [ ! -s "${shell_scripts}" ] || [ ! -s "${modified_files}" ]; then | ||
echo "No modified shell scripts detected" | ||
exit 0 | ||
fi | ||
if ! grep -Fxf "${shell_scripts}" "${modified_files}" > "${modified_shell_scripts}"; then | ||
echo "No modified shell scripts detected" | ||
exit 0 | ||
fi | ||
} | ||
git fetch origin "${GITHUB_BASE_REF}" || exit 1 | ||
find_modified_shell_scripts | ||
# Loop through the modified shell scripts | ||
while IFS= read -r modified_shell_script; do | ||
run_shellcheck "${modified_shell_script}" | ||
done < ${modified_shell_scripts} | ||
# If shellcheck reported any findings, fail the workflow | ||
if [ ${num_findings} -gt 0 ]; then | ||
echo "shellcheck reported ${num_findings} findings." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.