mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-01-31 15:53:10 +08:00
ci: refactor workflows (#6728)
Signed-off-by: Dwi Siswanto <git@dw1.io>
This commit is contained in:
30
.github/workflows/auto-merge.yaml
vendored
30
.github/workflows/auto-merge.yaml
vendored
@@ -1,28 +1,24 @@
|
|||||||
name: 🤖 Auto Merge
|
name: 🔀 Auto merge PR
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request_review:
|
# pull_request:
|
||||||
types: [submitted]
|
# types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
# pull_request_review:
|
||||||
|
# types: [submitted]
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: ["♾️ Compatibility Check"]
|
workflows: ["♾️ Compatibility Checks"]
|
||||||
types:
|
types: [completed]
|
||||||
- completed
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
issues: write
|
|
||||||
repository-projects: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
auto-merge:
|
auto-merge-dependabot:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.actor == 'dependabot[bot]'
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: projectdiscovery/actions/pr/approve@v1
|
||||||
|
- uses: projectdiscovery/actions/pr/merge@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.DEPENDABOT_PAT }}
|
auto: "true"
|
||||||
|
|
||||||
- uses: ahmadnassri/action-dependabot-auto-merge@v2
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.DEPENDABOT_PAT }}
|
|
||||||
target: all
|
|
||||||
4
.github/workflows/compat-checks.yaml
vendored
4
.github/workflows/compat-checks.yaml
vendored
@@ -7,8 +7,8 @@ on:
|
|||||||
- dev
|
- dev
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
compat-checks:
|
||||||
if: github.actor == 'dependabot[bot]'
|
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|||||||
61
.github/workflows/flamegraph.yaml
vendored
Normal file
61
.github/workflows/flamegraph.yaml
vendored
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
name: 📊 Flamegraph
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
flamegraph:
|
||||||
|
name: "Flamegraph"
|
||||||
|
env:
|
||||||
|
PROFILE_MEM: "/tmp/nuclei-profile"
|
||||||
|
TARGET_URL: "http://honey.scanme.sh/-/?foo=bar"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: projectdiscovery/actions/setup/go@v1
|
||||||
|
- uses: projectdiscovery/actions/cache/go-rod-browser@v1
|
||||||
|
- uses: projectdiscovery/actions/cache/nuclei@v1
|
||||||
|
- run: make build
|
||||||
|
|
||||||
|
- name: "Setup environment (push)"
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
run: |
|
||||||
|
echo "PROFILE_MEM=${PROFILE_MEM}-${GITHUB_REF_NAME}-${GITHUB_SHA}" >> $GITHUB_ENV
|
||||||
|
echo "FLAMEGRAPH_NAME=nuclei-${GITHUB_REF_NAME} (${GITHUB_SHA})" >> $GITHUB_ENV
|
||||||
|
- name: "Setup environment (pull_request)"
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
run: |
|
||||||
|
echo "PROFILE_MEM=${PROFILE_MEM}-pr-${{ github.event.number }}" >> $GITHUB_ENV
|
||||||
|
echo "FLAMEGRAPH_NAME=nuclei (PR #${{ github.event.number }})" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- run: ./bin/nuclei -update-templates
|
||||||
|
- run: |
|
||||||
|
./bin/nuclei -silent -target="${TARGET_URL}" \
|
||||||
|
-disable-update-check \
|
||||||
|
-no-mhe -no-httpx \
|
||||||
|
-code -dast -file -headless \
|
||||||
|
-enable-self-contained -enable-global-matchers \
|
||||||
|
-rate-limit=0 \
|
||||||
|
-concurrency=250 \
|
||||||
|
-headless-concurrency=100 \
|
||||||
|
-payload-concurrency=250 \
|
||||||
|
-bulk-size=250 \
|
||||||
|
-headless-bulk-size=100 \
|
||||||
|
-profile-mem="${PROFILE_MEM}"
|
||||||
|
|
||||||
|
- uses: projectdiscovery/actions/flamegraph@v1
|
||||||
|
id: flamegraph-cpu
|
||||||
|
with:
|
||||||
|
profile: "${{ env.PROFILE_MEM }}.cpu"
|
||||||
|
name: "${{ env.FLAMEGRAPH_NAME }} CPU profiles"
|
||||||
|
continue-on-error: true
|
||||||
|
- uses: projectdiscovery/actions/flamegraph@v1
|
||||||
|
id: flamegraph-mem
|
||||||
|
with:
|
||||||
|
profile: "${{ env.PROFILE_MEM }}.mem"
|
||||||
|
name: "${{ env.FLAMEGRAPH_NAME }} memory profiles"
|
||||||
|
continue-on-error: true
|
||||||
|
- if: ${{ steps.flamegraph-mem.outputs.message == '' }}
|
||||||
|
run: |
|
||||||
|
echo "::notice::CPU flamegraph: ${{ steps.flamegraph-cpu.outputs.url }}"
|
||||||
|
echo "::notice::Memory (heap) flamegraph: ${{ steps.flamegraph-mem.outputs.url }}"
|
||||||
4
.github/workflows/generate-docs.yaml
vendored
4
.github/workflows/generate-docs.yaml
vendored
@@ -4,11 +4,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
workflow_dispatch:
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-docs:
|
publish-docs:
|
||||||
if: "${{ !endsWith(github.actor, '[bot]') }}"
|
if: ${{ !endsWith(github.actor, '[bot]') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|||||||
66
.github/workflows/generate-pgo.yaml
vendored
66
.github/workflows/generate-pgo.yaml
vendored
@@ -1,56 +1,50 @@
|
|||||||
name: 👤 Generate PGO
|
name: 👤 Generate PGO
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch: {}
|
||||||
branches: ["dev"]
|
workflow_call: {}
|
||||||
paths:
|
|
||||||
- '**.go'
|
|
||||||
- '**.mod'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
# TODO(dwisiswant0): https://go.dev/doc/pgo#merging-profiles
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pgo:
|
pgo:
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
targets: [150]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.repository == 'projectdiscovery/nuclei'
|
if: github.repository == 'projectdiscovery/nuclei'
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
env:
|
env:
|
||||||
PGO_FILE: "cmd/nuclei/default.pgo"
|
PGO_FILE: "cmd/nuclei/default.pgo"
|
||||||
LIST_FILE: "/tmp/targets-${{ matrix.targets }}.txt"
|
TARGET: "https://honey.scanme.sh"
|
||||||
PROFILE_MEM: "/tmp/nuclei-profile-${{ matrix.targets }}-targets"
|
TARGET_COUNT: "100"
|
||||||
|
TARGET_LIST: "/tmp/targets.txt"
|
||||||
|
PROFILE_MEM: "/tmp/nuclei-profile"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: projectdiscovery/actions/setup/git@v1
|
|
||||||
- uses: projectdiscovery/actions/setup/go@v1
|
- uses: projectdiscovery/actions/setup/go@v1
|
||||||
|
- uses: projectdiscovery/actions/cache/go-rod-browser@v1
|
||||||
- uses: projectdiscovery/actions/cache/nuclei@v1
|
- uses: projectdiscovery/actions/cache/nuclei@v1
|
||||||
- name: Generate list
|
- run: |
|
||||||
run: for i in {1..${{ matrix.targets }}}; do echo "https://honey.scanme.sh/?_=${i}" >> "${LIST_FILE}"; done
|
for i in {1..${{ env.TARGET_COUNT }}}; do
|
||||||
# NOTE(dwisiswant0): use `-no-mhe` flag to get better samples.
|
echo "${{ env.TARGET }}/-/?_=${i}" >> "${{ env.TARGET_LIST }}";
|
||||||
- run: go run . -l "${LIST_FILE}" -profile-mem="${PROFILE_MEM}" -no-mhe
|
done
|
||||||
working-directory: cmd/nuclei/
|
- run: make build
|
||||||
- run: mv "${PROFILE_MEM}.cpu" ${PGO_FILE}
|
- run: ./bin/nuclei -update-templates
|
||||||
# NOTE(dwisiswant0): shall we prune $PGO_FILE git history?
|
- run: |
|
||||||
# if we prune it, this won't be linear since it requires a force-push.
|
./bin/nuclei -silent -list="${TARGET_LIST}" \
|
||||||
# if we don't, the git objects will just keep growing bigger.
|
-disable-update-check \
|
||||||
#
|
-no-mhe -no-httpx \
|
||||||
# Ref:
|
-code -dast -file -headless \
|
||||||
# - https://go.dev/blog/pgo#:~:text=We%20recommend%20committing%20default.pgo%20files%20to%20your%20repository
|
-enable-self-contained -enable-global-matchers \
|
||||||
# - https://gist.github.com/nottrobin/5758221
|
-rate-limit=0 \
|
||||||
- uses: projectdiscovery/actions/commit@v1
|
-concurrency=250 \
|
||||||
with:
|
-headless-concurrency=100 \
|
||||||
files: "${PGO_FILE}"
|
-payload-concurrency=250 \
|
||||||
message: "build: update PGO profile :robot:"
|
-bulk-size=250 \
|
||||||
- run: git push origin $GITHUB_REF
|
-headless-bulk-size=100 \
|
||||||
|
-profile-mem="${PROFILE_MEM}" \
|
||||||
|
env:
|
||||||
|
DISABLE_STDOUT: "1"
|
||||||
|
- run: mv "${PROFILE_MEM}.cpu" "${PGO_FILE}"
|
||||||
- uses: actions/upload-artifact@v6
|
- uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: "pgo"
|
name: "pgo"
|
||||||
path: "${{ env.PGO_FILE }}"
|
path: "${{ env.PGO_FILE }}"
|
||||||
|
overwrite: true
|
||||||
|
|||||||
2
.github/workflows/govulncheck.yaml
vendored
2
.github/workflows/govulncheck.yaml
vendored
@@ -3,7 +3,7 @@ name: 🐛 govulncheck
|
|||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * 0' # Weekly
|
- cron: '0 0 * * 0' # Weekly
|
||||||
workflow_dispatch:
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
govulncheck:
|
govulncheck:
|
||||||
|
|||||||
4
.github/workflows/perf-regression.yaml
vendored
4
.github/workflows/perf-regression.yaml
vendored
@@ -1,8 +1,8 @@
|
|||||||
name: 🔨 Performance Regression
|
name: 🔨 Performance Regression
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call: {}
|
||||||
workflow_dispatch:
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
perf-regression:
|
perf-regression:
|
||||||
|
|||||||
43
.github/workflows/perf-test.yaml
vendored
43
.github/workflows/perf-test.yaml
vendored
@@ -1,43 +0,0 @@
|
|||||||
name: 🔨 Performance Test
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * 0' # Weekly
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
perf-test:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
count: [50, 100, 150]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.repository == 'projectdiscovery/nuclei'
|
|
||||||
env:
|
|
||||||
LIST_FILE: "/tmp/targets-${{ matrix.count }}.txt"
|
|
||||||
PROFILE_MEM: "/tmp/nuclei-perf-test-${{ matrix.count }}"
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: projectdiscovery/actions/setup/go@v1
|
|
||||||
- run: make verify
|
|
||||||
- name: Generate list
|
|
||||||
run: for i in {1..${{ matrix.count }}}; do echo "https://honey.scanme.sh/?_=${i}" >> "${LIST_FILE}"; done
|
|
||||||
- run: go run . -l "${LIST_FILE}" -profile-mem="${PROFILE_MEM}"
|
|
||||||
env:
|
|
||||||
NUCLEI_ARGS: host-error-stats
|
|
||||||
working-directory: cmd/nuclei/
|
|
||||||
- uses: projectdiscovery/actions/flamegraph@v1
|
|
||||||
id: flamegraph-cpu
|
|
||||||
with:
|
|
||||||
profile: "${{ env.PROFILE_MEM }}.cpu"
|
|
||||||
name: "${{ env.FLAMEGRAPH_NAME }} CPU profiles"
|
|
||||||
continue-on-error: true
|
|
||||||
- uses: projectdiscovery/actions/flamegraph@v1
|
|
||||||
id: flamegraph-mem
|
|
||||||
with:
|
|
||||||
profile: "${{ env.PROFILE_MEM }}.mem"
|
|
||||||
name: "${{ env.FLAMEGRAPH_NAME }} memory profiles"
|
|
||||||
continue-on-error: true
|
|
||||||
- if: ${{ steps.flamegraph-mem.outputs.message == '' }}
|
|
||||||
run: |
|
|
||||||
echo "::notice::CPU flamegraph: ${{ steps.flamegraph-cpu.outputs.url }}"
|
|
||||||
echo "::notice::Memory (heap) flamegraph: ${{ steps.flamegraph-mem.outputs.url }}"
|
|
||||||
14
.github/workflows/release.yaml
vendored
14
.github/workflows/release.yaml
vendored
@@ -4,16 +4,28 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
workflow_dispatch:
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
pgo:
|
||||||
|
name: "Generate PGO"
|
||||||
|
uses: ./.github/workflows/generate-pgo.yaml
|
||||||
|
|
||||||
release:
|
release:
|
||||||
|
name: "Release"
|
||||||
|
needs: ["pgo"]
|
||||||
runs-on: ubuntu-latest-16-cores
|
runs-on: ubuntu-latest-16-cores
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- uses: actions/download-artifact@v6
|
||||||
|
with:
|
||||||
|
name: "pgo"
|
||||||
|
path: "cmd/nuclei/"
|
||||||
- uses: projectdiscovery/actions/setup/go@v1
|
- uses: projectdiscovery/actions/setup/go@v1
|
||||||
|
with:
|
||||||
|
go-version: "stable"
|
||||||
- uses: docker/login-action@v3
|
- uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
|||||||
39
.github/workflows/tests.yaml
vendored
39
.github/workflows/tests.yaml
vendored
@@ -19,7 +19,7 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: "Lint"
|
name: "Lint"
|
||||||
if: "${{ !endsWith(github.actor, '[bot]') }}"
|
if: ${{ !endsWith(github.actor, '[bot]') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
@@ -157,42 +157,9 @@ jobs:
|
|||||||
flamegraph:
|
flamegraph:
|
||||||
name: "Flamegraph"
|
name: "Flamegraph"
|
||||||
needs: ["tests"]
|
needs: ["tests"]
|
||||||
env:
|
uses: ./.github/workflows/flamegraph.yaml
|
||||||
PROFILE_MEM: "/tmp/nuclei"
|
|
||||||
TARGET_URL: "http://scanme.sh/a/?b=c"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- run: make build
|
|
||||||
- name: "Setup environment (push)"
|
|
||||||
if: ${{ github.event_name == 'push' }}
|
|
||||||
run: |
|
|
||||||
echo "PROFILE_MEM=${PROFILE_MEM}-${GITHUB_REF_NAME}-${GITHUB_SHA}" >> $GITHUB_ENV
|
|
||||||
echo "FLAMEGRAPH_NAME=nuclei-${GITHUB_REF_NAME} (${GITHUB_SHA})" >> $GITHUB_ENV
|
|
||||||
- name: "Setup environment (pull_request)"
|
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
|
||||||
run: |
|
|
||||||
echo "PROFILE_MEM=${PROFILE_MEM}-pr-${{ github.event.number }}" >> $GITHUB_ENV
|
|
||||||
echo "FLAMEGRAPH_NAME=nuclei (PR #${{ github.event.number }})" >> $GITHUB_ENV
|
|
||||||
- run: ./bin/nuclei -silent -update-templates
|
|
||||||
- run: ./bin/nuclei -silent -u "${TARGET_URL}" -profile-mem="${PROFILE_MEM}"
|
|
||||||
- uses: projectdiscovery/actions/flamegraph@v1
|
|
||||||
id: flamegraph-cpu
|
|
||||||
with:
|
|
||||||
profile: "${{ env.PROFILE_MEM }}.cpu"
|
|
||||||
name: "${{ env.FLAMEGRAPH_NAME }} CPU profiles"
|
|
||||||
continue-on-error: true
|
|
||||||
- uses: projectdiscovery/actions/flamegraph@v1
|
|
||||||
id: flamegraph-mem
|
|
||||||
with:
|
|
||||||
profile: "${{ env.PROFILE_MEM }}.mem"
|
|
||||||
name: "${{ env.FLAMEGRAPH_NAME }} memory profiles"
|
|
||||||
continue-on-error: true
|
|
||||||
- if: ${{ steps.flamegraph-mem.outputs.message == '' }}
|
|
||||||
run: |
|
|
||||||
echo "::notice::CPU flamegraph: ${{ steps.flamegraph-cpu.outputs.url }}"
|
|
||||||
echo "::notice::Memory (heap) flamegraph: ${{ steps.flamegraph-mem.outputs.url }}"
|
|
||||||
|
|
||||||
perf-regression:
|
perf-regression:
|
||||||
|
name: "Performance regression"
|
||||||
needs: ["tests"]
|
needs: ["tests"]
|
||||||
uses: ./.github/workflows/perf-regression.yaml
|
uses: ./.github/workflows/perf-regression.yaml
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ builds:
|
|||||||
id: nuclei-cli
|
id: nuclei-cli
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
goos: [windows,linux,darwin]
|
- GOEXPERIMENT=greenteagc
|
||||||
goarch: [amd64,'386',arm,arm64]
|
goos: [windows, linux, darwin]
|
||||||
|
goarch: [amd64, '386', arm, arm64]
|
||||||
ignore:
|
ignore:
|
||||||
- goos: darwin
|
- goos: darwin
|
||||||
goarch: '386'
|
goarch: '386'
|
||||||
|
|||||||
Reference in New Issue
Block a user