Conversation
Draft: Add logs to help with debugging
Remove logging
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow intended to enable remote debugging, and updates the existing PR build workflow by disabling Trivy scanning.
Changes:
- Commented out the
trivy-scansjob in the PR build workflow. - Added a new workflow (
ngrok.yaml) that starts an interactive upterm session on runner execution.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| .github/workflows/pr_build.yml | Disables (comments out) the Trivy scan job for PR builds. |
| .github/workflows/ngrok.yaml | Introduces a push-triggered workflow that checks out code and starts an upterm session, exporting several secrets into the environment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.github/workflows/pr_build.yml
Outdated
| # trivy-scans: | ||
| # if: (github.base_ref == 'develop' || github.base_ref == 'main' || github.base_ref == 'master' ) && github.event.pull_request.merged == false | ||
| # uses: kbase/.github/.github/workflows/reusable_trivy-scans.yml@main | ||
| # secrets: inherit |
There was a problem hiding this comment.
Trivy scanning job has been fully commented out, which removes vulnerability scanning from PR builds. If this is intended to be temporary, consider gating it behind an explicit opt-out input/label or fixing the underlying failure so the scans still run for eligible PRs.
| # trivy-scans: | |
| # if: (github.base_ref == 'develop' || github.base_ref == 'main' || github.base_ref == 'master' ) && github.event.pull_request.merged == false | |
| # uses: kbase/.github/.github/workflows/reusable_trivy-scans.yml@main | |
| # secrets: inherit | |
| trivy-scans: | |
| if: (github.base_ref == 'develop' || github.base_ref == 'main' || github.base_ref == 'master') && github.event.pull_request.merged == false && !contains(join(github.event.pull_request.labels.*.name, ','), 'skip-trivy-scan') | |
| uses: kbase/.github/.github/workflows/reusable_trivy-scans.yml@main | |
| secrets: inherit |
.github/workflows/ngrok.yaml
Outdated
| - uses: actions/checkout@v2 | ||
|
|
||
| - name: Setup upterm session | ||
| uses: lhotari/action-upterm@v1 | ||
| env: | ||
| KBASE_CI_TOKEN: ${{ secrets.KBASE_CI_TOKEN }} | ||
| KBASE_CI_TOKEN2: ${{ secrets.KBASE_CI_TOKEN2 }} | ||
| KBASE_TEST_TOKEN: ${{ secrets.KBASE_TEST_TOKEN }} | ||
| KBASE_TEST_TOKEN2: ${{ secrets.KBASE_TEST_TOKEN2 }} | ||
| KBASE_BOT_TOKEN_CI: ${{ secrets.KBASE_BOT_TOKEN_CI }} | ||
| KBASE_BOT_USER_CI: ${{ secrets.KBASE_BOT_USER_CI }} | ||
| GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} |
There was a problem hiding this comment.
The steps: list is not indented correctly. The - uses: actions/checkout@v2 item (and following steps) must be nested under steps: (e.g., additional indentation) or the workflow YAML will be invalid and fail to load.
| - uses: actions/checkout@v2 | |
| - name: Setup upterm session | |
| uses: lhotari/action-upterm@v1 | |
| env: | |
| KBASE_CI_TOKEN: ${{ secrets.KBASE_CI_TOKEN }} | |
| KBASE_CI_TOKEN2: ${{ secrets.KBASE_CI_TOKEN2 }} | |
| KBASE_TEST_TOKEN: ${{ secrets.KBASE_TEST_TOKEN }} | |
| KBASE_TEST_TOKEN2: ${{ secrets.KBASE_TEST_TOKEN2 }} | |
| KBASE_BOT_TOKEN_CI: ${{ secrets.KBASE_BOT_TOKEN_CI }} | |
| KBASE_BOT_USER_CI: ${{ secrets.KBASE_BOT_USER_CI }} | |
| GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} | |
| - uses: actions/checkout@v2 | |
| - name: Setup upterm session | |
| uses: lhotari/action-upterm@v1 | |
| env: | |
| KBASE_CI_TOKEN: ${{ secrets.KBASE_CI_TOKEN }} | |
| KBASE_CI_TOKEN2: ${{ secrets.KBASE_CI_TOKEN2 }} | |
| KBASE_TEST_TOKEN: ${{ secrets.KBASE_TEST_TOKEN }} | |
| KBASE_TEST_TOKEN2: ${{ secrets.KBASE_TEST_TOKEN2 }} | |
| KBASE_BOT_TOKEN_CI: ${{ secrets.KBASE_BOT_TOKEN_CI }} | |
| KBASE_BOT_USER_CI: ${{ secrets.KBASE_BOT_USER_CI }} | |
| GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} |
.github/workflows/ngrok.yaml
Outdated
| @@ -0,0 +1,18 @@ | |||
| name: CI | |||
| on: [push] | |||
There was a problem hiding this comment.
This workflow is triggered on every push, but it sets up an interactive upterm session. That effectively creates a remote shell on every push and can be used to exfiltrate data; it should be restricted (e.g., workflow_dispatch only, and ideally limited to specific branches/actors).
| on: [push] | |
| on: | |
| workflow_dispatch: |
.github/workflows/ngrok.yaml
Outdated
| KBASE_TEST_TOKEN2: ${{ secrets.KBASE_TEST_TOKEN2 }} | ||
| KBASE_BOT_TOKEN_CI: ${{ secrets.KBASE_BOT_TOKEN_CI }} | ||
| KBASE_BOT_USER_CI: ${{ secrets.KBASE_BOT_USER_CI }} | ||
| GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} |
There was a problem hiding this comment.
Multiple long-lived secrets are exported into the environment of an interactive session. This materially increases the risk of secret exposure; avoid injecting these secrets into the upterm session (or switch to short-lived credentials / only provide the minimum required secret(s)).
| GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} |
.github/workflows/ngrok.yaml
Outdated
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 |
There was a problem hiding this comment.
actions/checkout@v2 is outdated and has known issues compared to newer major versions. Update to the current supported actions/checkout@v4 unless there is a compatibility constraint.
| - uses: actions/checkout@v2 | |
| - uses: actions/checkout@v4 |
.github/workflows/ngrok.yaml
Outdated
| @@ -0,0 +1,18 @@ | |||
| name: CI | |||
There was a problem hiding this comment.
File/workflow naming is confusing: the workflow file is ngrok.yaml, but it configures an upterm session and the workflow name is the generic CI. Consider renaming the workflow/file (or adjusting the content) so it reflects its purpose and doesn't look like the primary CI pipeline.
| name: CI | |
| name: Upterm debug session (ngrok) |
| runs-on: ubuntu-latest | ||
| env: | ||
| GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} | ||
| steps: | ||
| - name: Check token scopes | ||
| run: | | ||
| curl -sI \ | ||
| -H "Authorization: Bearer $GHCR_TOKEN" \ | ||
| https://api.github.com/user \ | ||
| | grep -i "x-oauth-scopes\|x-accepted-oauth-scopes" | ||
|
|
||
| - name: Check token owner | ||
| run: | | ||
| curl -s \ | ||
| -H "Authorization: Bearer $GHCR_TOKEN" \ | ||
| https://api.github.com/user \ | ||
| | jq '{login, type, site_admin}' |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
In general, this problem is fixed by explicitly declaring a permissions block either at the workflow root (applies to all jobs) or per-job, and setting it to the minimal access needed. For this specific workflow, the job only uses a custom secret and calls the GitHub API; it does not perform any write operations. The safest and simplest fix is to add a root-level permissions block setting contents: read, which is the minimal common baseline and satisfies the CodeQL requirement while preserving behavior.
Concretely, in .github/workflows/ngrok.yaml, add a permissions: section after the on: declaration so it applies to all jobs. No additional imports or methods are needed because this is a YAML configuration change only. The rest of the workflow (the inspect job, environment variables, and steps) remains unchanged.
| @@ -1,5 +1,7 @@ | ||
| name: Inspect GHCR Token | ||
| on: [pull_request] | ||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| inspect: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #137 +/- ##
==========================================
Coverage ? 81.02%
==========================================
Files ? 8
Lines ? 2846
Branches ? 0
==========================================
Hits ? 2306
Misses ? 540
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Don't use, in favor of printing out what you need using AI