-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
ci(tests): add flamegraph job #5966
Conversation
Signed-off-by: Dwi Siswanto <git@dw1.io>
WalkthroughA new "Flamegraph" job has been added to the GitHub Actions workflow in Changes
Sequence DiagramsequenceDiagram
participant Tests as Tests Job
participant Flamegraph as Flamegraph Job
participant Nuclei as Nuclei Tool
participant FlamegraphAction as Flamegraph Action
Tests->>Flamegraph: Trigger after completion
Flamegraph->>Flamegraph: Checkout repository
Flamegraph->>Flamegraph: Build project
Flamegraph->>Nuclei: Update templates
Nuclei-->>Flamegraph: Templates updated
Flamegraph->>Nuclei: Run scan with profiling
Nuclei-->>Flamegraph: Scan complete
Flamegraph->>FlamegraphAction: Generate flamegraph
FlamegraphAction-->>Flamegraph: Flamegraph generated
Assessment against linked issues
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (4)
.github/workflows/tests.yaml (4)
137-143
: Consider using an internal test endpoint.The job setup looks good, but consider using an internal test endpoint instead of a public URL (
scanme.sh
) for more reliable and secure CI testing.
157-158
: Add error handling for nuclei commands.While the commands are correct, consider adding error handling to ensure the workflow fails appropriately if either command fails.
- - run: ./bin/nuclei -silent -update-templates - - run: ./bin/nuclei -silent -u "${TARGET_URL}" -profile-mem="${PROFILE_MEM}" + - name: Update nuclei templates + run: ./bin/nuclei -silent -update-templates + continue-on-error: false + - name: Run nuclei scan with profiling + run: ./bin/nuclei -silent -u "${TARGET_URL}" -profile-mem="${PROFILE_MEM}" + continue-on-error: false
159-168
: Add documentation for flamegraph URLs.The flamegraph generation and URL output look good. Consider adding a comment or documentation explaining where these flamegraphs are hosted and how long they are retained.
- uses: projectdiscovery/actions/flamegraph@master id: flamegraph with: profile: "${{ env.PROFILE_MEM }}.prof" name: "${{ env.FLAMEGRAPH_NAME }}" continue-on-error: true + # Flamegraphs are uploaded to Flamegraph.com and are publicly accessible + # The URL will be posted as a notice in the workflow run
137-168
: Consider workflow optimization for large repositories.The flamegraph job setup is well-structured. For large repositories with frequent commits, consider:
- Adding a conditional to run this job only on specific paths or tags
- Implementing caching for nuclei templates to speed up the workflow
Example condition:
flamegraph: if: | github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.modified, 'cmd/') || contains(github.event.head_commit.modified, 'pkg/') )🧰 Tools
🪛 actionlint (1.7.4)
149-149: shellcheck reported issue in this script: SC2086:info:1:71: Double quote to prevent globbing and word splitting
(shellcheck)
149-149: shellcheck reported issue in this script: SC2086:info:2:69: Double quote to prevent globbing and word splitting
(shellcheck)
154-154: shellcheck reported issue in this script: SC2086:info:1:68: Double quote to prevent globbing and word splitting
(shellcheck)
154-154: shellcheck reported issue in this script: SC2086:info:2:67: Double quote to prevent globbing and word splitting
(shellcheck)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/tests.yaml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/tests.yaml
149-149: shellcheck reported issue in this script: SC2086:info:1:71: Double quote to prevent globbing and word splitting
(shellcheck)
149-149: shellcheck reported issue in this script: SC2086:info:2:69: Double quote to prevent globbing and word splitting
(shellcheck)
154-154: shellcheck reported issue in this script: SC2086:info:1:68: Double quote to prevent globbing and word splitting
(shellcheck)
154-154: shellcheck reported issue in this script: SC2086:info:2:67: Double quote to prevent globbing and word splitting
(shellcheck)
- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix shell script quoting issues.
The shell scripts should use proper quoting to prevent globbing and word splitting issues.
Apply this diff:
- echo "PROFILE_MEM=${PROFILE_MEM}-${GITHUB_REF_NAME}-${GITHUB_SHA}" >> $GITHUB_ENV
- echo "FLAMEGRAPH_NAME=nuclei-${GITHUB_REF_NAME} (${GITHUB_SHA})" >> $GITHUB_ENV
+ echo "PROFILE_MEM=${PROFILE_MEM}-${GITHUB_REF_NAME}-${GITHUB_SHA}" >> "${GITHUB_ENV}"
+ echo "FLAMEGRAPH_NAME=nuclei-${GITHUB_REF_NAME} (${GITHUB_SHA})" >> "${GITHUB_ENV}"
- echo "PROFILE_MEM=${PROFILE_MEM}-pr-${{ github.event.number }}" >> $GITHUB_ENV
- echo "FLAMEGRAPH_NAME=nuclei (PR #${{ github.event.number }})" >> $GITHUB_ENV
+ echo "PROFILE_MEM=${PROFILE_MEM}-pr-${{ github.event.number }}" >> "${GITHUB_ENV}"
+ echo "FLAMEGRAPH_NAME=nuclei (PR #${{ github.event.number }})" >> "${GITHUB_ENV}"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- 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 | |
- 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}" |
🧰 Tools
🪛 actionlint (1.7.4)
149-149: shellcheck reported issue in this script: SC2086:info:1:71: Double quote to prevent globbing and word splitting
(shellcheck)
149-149: shellcheck reported issue in this script: SC2086:info:2:69: Double quote to prevent globbing and word splitting
(shellcheck)
154-154: shellcheck reported issue in this script: SC2086:info:1:68: Double quote to prevent globbing and word splitting
(shellcheck)
154-154: shellcheck reported issue in this script: SC2086:info:2:67: Double quote to prevent globbing and word splitting
(shellcheck)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposed changes
Close #5965
https://flamegraph.com/share/1736bd3a-ce74-11ef-9832-26c3e5347170
Checklist
Summary by CodeRabbit