-
Notifications
You must be signed in to change notification settings - Fork 0
Stabilize failing GitHub workflows and align repo tooling #27
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
base: main
Are you sure you want to change the base?
Changes from all commits
eb9e515
61d41e2
48bdf0e
2acef85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,42 +28,46 @@ | |
|
|
||
| name: EthicalCheck-Workflow | ||
|
|
||
| # Controls when the workflow will run | ||
| on: | ||
| # Triggers the workflow on push or pull request events but only for the "main" branch | ||
| # Customize trigger events based on your DevSecOps processes. | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| schedule: | ||
| - cron: '37 9 * * 2' | ||
|
|
||
| # Allows you to run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
|
|
||
|
Comment on lines
31
to
35
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| Trigger_EthicalCheck: | ||
| permissions: | ||
| security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | ||
| actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
| trigger_ethicalcheck: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| APISEC_BASE_URL: ${{ vars.APISEC_BASE_URL }} | ||
| APISEC_SPECIFICATION_PATH: ${{ vars.APISEC_SPECIFICATION_PATH }} | ||
| APISECU_TOKEN: ${{ secrets.APISECU_TOKEN }} | ||
|
|
||
| steps: | ||
| - name: EthicalCheck Free & Automated API Security Testing Service | ||
| uses: apisec-inc/ethicalcheck-action@005fac321dd843682b1af6b72f30caaf9952c641 | ||
| with: | ||
| # The OpenAPI Specification URL or Swagger Path or Public Postman collection URL. | ||
| oas-url: "http://netbanking.apisec.ai:8080/v2/api-docs" | ||
| # The email address to which the penetration test report will be sent. | ||
| email: "xxx@apisec.ai" | ||
| sarif-result-file: "ethicalcheck-results.sarif" | ||
|
|
||
| - name: Upload sarif file to repository | ||
| uses: github/codeql-action/upload-sarif@v3 | ||
| with: | ||
| sarif_file: ./ethicalcheck-results.sarif | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Validate EthicalCheck configuration | ||
| id: config | ||
| run: | | ||
| if [ -z "${APISEC_BASE_URL}" ] || [ -z "${APISEC_SPECIFICATION_PATH}" ] || [ -z "${APISECU_TOKEN}" ]; then | ||
| echo "configured=false" >> "${GITHUB_OUTPUT}" | ||
| echo "ℹ️ EthicalCheck is not configured. Set APISEC_BASE_URL, APISEC_SPECIFICATION_PATH, and APISECU_TOKEN to enable scans." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ ! -f "${APISEC_SPECIFICATION_PATH}" ]; then | ||
| echo "Configured OpenAPI specification file not found: ${APISEC_SPECIFICATION_PATH}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "configured=true" >> "${GITHUB_OUTPUT}" | ||
|
|
||
| - name: Run APIsec scan | ||
| if: steps.config.outputs.configured == 'true' | ||
| uses: apisec-university/free-API-security-test-action@beta | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 4. A mutable action can expose scan secrets The Run APIsec scan step references the third-party action through the movable beta tag while passing it APISECU_TOKEN. If that tag is moved or its repository is compromised, scheduled and manually dispatched jobs execute the replacement code with the APIsec credential and read access to the repository. Agent Prompt
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot - ## Issue description Issue ContextThe replaced EthicalCheck action was pinned to a full commit SHA, and other third-party workflows in this repository follow the same pattern. Preserve the action inputs and configuration gate while replacing only the mutable reference. Fix Focus Areas
|
||
| with: | ||
|
Comment on lines
+67
to
+70
|
||
| base_url: ${{ env.APISEC_BASE_URL }} | ||
| specification_path: ${{ env.APISEC_SPECIFICATION_PATH }} | ||
| apisecu_token: ${{ env.APISECU_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,15 +246,7 @@ private function configureR2(): void | |
| throw new RuntimeException('STARMUS_R2_SECRET_KEY is not defined or is empty.'); | ||
| } | ||
|
|
||
| if (! \defined('STARMUS_R2_ENDPOINT')) { | ||
| throw new RuntimeException('STARMUS_R2_ENDPOINT is not defined or is empty.'); | ||
| } | ||
| // Read via constant() so static analysis cannot infer the literal value; this | ||
| // preserves the empty-string guard when wp-config.php defines the constant as ''. | ||
| $r2_endpoint = (string) \constant('STARMUS_R2_ENDPOINT'); | ||
| if (trim($r2_endpoint) === '') { | ||
| throw new RuntimeException('STARMUS_R2_ENDPOINT is not defined or is empty.'); | ||
| } | ||
| $r2_endpoint = $this->getRequiredStringConstant('STARMUS_R2_ENDPOINT'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Reviewers must assess unrelated fixes The PR combines workflow runtime changes, an API security action replacement, build-validator repair, broad JavaScript formatting, and an R2 constant-loading refactor in one change set. Because the workflow, validator, formatting, and PHP groups can be removed independently without making the others incoherent, reviewers must validate several unrelated failure modes together. Agent Prompt
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot - ## Issue description Issue ContextSeparate workflow/runtime repair, APIsec workflow replacement, build validation, formatting-only changes, and PHP constant handling into focused pull requests with their relevant tests. Fix Focus Areas
|
||
|
|
||
| $this->bucket = \defined('STARMUS_R2_BUCKET') ? STARMUS_R2_BUCKET : 'starmus-audio'; | ||
| $account_id = STARMUS_R2_ACCOUNT_ID; | ||
|
|
@@ -301,6 +293,27 @@ private function configureAws(): void | |
| ]); | ||
| } | ||
|
|
||
| private function getRequiredStringConstant(string $constant_name): string | ||
| { | ||
|
Comment on lines
+296
to
+297
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Maintainers inherit conflicting styles getRequiredStringConstant() uses a camelCase method name and a PSR-style next-line opening brace in WordPress-integrated source, with no inline waiver. When the repository's WordPress naming and core rules scan src/, this newly added helper conflicts with the preferred style and gives later additions two conventions to follow. Agent Prompt
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot - ## Issue description Issue ContextRename the helper and its call site using WordPress snake_case, and place the opening brace according to the applicable WordPress standard. Update any references consistently. Fix Focus Areas
|
||
| if (! \defined($constant_name)) { | ||
| throw new RuntimeException(\sprintf('%s is not defined or is empty.', $constant_name)); | ||
| } | ||
|
|
||
|
Comment on lines
+298
to
+301
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Php changes can merge without tests getRequiredStringConstant() adds validation behavior, but the changed workflows run PHP static analysis and WordPress activation or end-to-end checks without invoking the configured PHPUnit suite. When endpoint constants are undefined, non-scalar, or empty, no required CI job exercises those branches, so a regression in the new helper can merge undetected. Agent Prompt
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot - ## Issue description Issue ContextAdd a blocking PHP unit-test step and cover undefined, non-scalar, empty, and valid string constants. Keep the existing static-analysis step blocking. Fix Focus Areas
|
||
| $constant_value = \constant($constant_name); | ||
|
|
||
| if (! \is_scalar($constant_value)) { | ||
| throw new RuntimeException(\sprintf('%s is not defined or is empty.', $constant_name)); | ||
| } | ||
|
|
||
| $resolved_value = (string) $constant_value; | ||
|
|
||
| if ($resolved_value === '') { | ||
| throw new RuntimeException(\sprintf('%s is not defined or is empty.', $constant_name)); | ||
| } | ||
|
|
||
| return $resolved_value; | ||
| } | ||
|
Comment on lines
+296
to
+315
Comment on lines
+308
to
+315
|
||
|
|
||
| private function createOptimizedVersion(string $input, array $params): ?string | ||
| { | ||
| $temp_file = tempnam(sys_get_temp_dir(), 'starmus_africa_') . '.mp3'; | ||
|
|
||
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.
5. Merges skip api security scans
🐞 Bug⛨ SecurityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation toolsThere 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.
@copilot - ## Issue description
The repaired API security workflow no longer runs on pushes or pull requests because both event triggers were removed. Restore appropriate change-triggered execution while retaining the existing configuration gate so unconfigured repositories and forked pull requests skip cleanly.
Issue Context
The previous workflow targeted pushes and pull requests to
main. The new weekly schedule can complement those triggers but does not scan each update before or when it reaches the main branch.Fix Focus Areas