Skip to content
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

[Bug]: Unkown Exception was hit #119

Open
1 task done
Brutalbeard opened this issue Jun 6, 2024 · 18 comments
Open
1 task done

[Bug]: Unkown Exception was hit #119

Brutalbeard opened this issue Jun 6, 2024 · 18 comments
Assignees
Labels
bug Something isn't working

Comments

@Brutalbeard
Copy link

What happened?

I'm working on a test repo in my company's org (hid the name in all the screenshots that I'm going to attach. We have a policy which keeps us from interacting with outside repos using our corporate account).

This repo has several open security vulnerabilities and has had them for a long time. Was originally used as a test repo for comparing Veracode to GHAS (honestly a pointless comparison, GHAS is better by miles).
Screenshot 2024-06-06 at 12 47 33 PM
Screenshot 2024-06-06 at 12 48 45 PM

When I run the action though, with v2.7.3 I get errors that cause the action to fail, as one would expect given these security alerts on that repo, but no information about which alert caused the issue. I also get at least one of this error each run: Unknown Exception was hit, please repo this to https://github.com/advanced-security/policy-as-code

This is the included ID that comes up in logs: 'A4D3:360A1:447E699:78AAC10:666203F8'

Workflow File:

name: Policy Testing - No General Workflow

on:
    pull_request:
        branches: main
    push:
        branches: main

# workflow or job level
permissions:
    contents: read
    security-events: read
    # pull request summaries
    pull-requests: write

jobs:
    policy-check:
        runs-on: ubuntu-latest
        name: Policy Testing

        steps:
            # Compliance
            - name: Advance Security Policy as Code
              uses: advanced-security/[email protected]
              with:
                  # The owner/repo of where the policy is stored
                  policy: dat-freight-and-analytics/ghas-policy-as-code
                  # The local (within the workspace) or repository
                  policy-path: policies/default.yml
                  # The branch you want to target
                  policy-branch: main
                  policy-repo-token: ${{ secrets.GHAS_COMPLIANCE_PAT }}
                  argvs: '--display --pr-comment'

Policy Doc (which excludes licensing check):

# # Level Hierarchy
# - critical
# - high
# - error
# - medium
# - moderate
# - low
# - warning
# - notes

# default remediation policy
general:
  # All other blocks will be inheriting the remediate section if they don't have 
  #  their own defined.
  remediate:
    # Only `errors` and above have got 7 days to remediate according to the 
    #  policy
    errors: 90
    # Same here for anything regarding warnings but for 30 days
    warnings: 90

    # Any / All issues that haven't been defined by other catagories will have 
    #  the following remediation policy applied. 
    all: 90
  
# ------------ #

# the `codescanning` block will inherit the `general` block
codescanning:
  # If `level` is also set with `remediate` turned on then both the level check 
  #  and time to remediate time frame checks are done. 
  # In this example, if `level: error` is set and a warning is reported and 
  #  violated the time to remediate check (has exceeded the time to fix the 
  #  issue) then it will NOT be reported.
  level: error

  # Conditions will only trigger and raise an error when an exact match is hit
  # conditions:
  #   ids:
  #     # Code Scanning Rule identifier
  #     - js/sql-injection
  # # Ignores are run next so if an ignored rule is hit that matches the level, it will be skipped
  ignores:
    ids:
      - js/log-injection
    names:
      # Code Scanning Rule name
      - "Missing rate limiting"

# ------------ #

dependabot:
  # This block will not inherit the `general` remediate block
  remediate:
    # The team have 7 days before this starts crashing workflows / builds
    high: 7

  # Conditions will only trigger and raise an error when an exact match is hit
  # conditions:
  #   ids:
  #     # GitHub Security Advisory ID
  #     - GHSA-446m-mv8f-q348
  #     # CWE data from GitHub Advisory Database
  #     - CWE-89
  # # Ignores are run next so if an ignored rule is hit that matches the level, it will be skipped
  # ignores:
  #   ids:
  #     - GHSA-mh5c-679w-hh4r

# ------------ #

# licensing:
  # Licensing does not have `remediate` block as there are no dates associated 
  #  with the discovery of a dependency with licensing issues. This may change 
  #  in the future but currently isn't available.

  # # Conditions will only trigger and raise an error when an exact match is hit
  # conditions:
  #   ids:
  #     # License identifiers
  #     - GPL-2.0
  #     - GPL-3.0
  #   names:
  #     # Dependency Name (manager + name), best to use as this makes sure that
  #     #  the right package manager is used
  #     - maven://org.apache.struts
  #     # Dependency Short Name (just name)
  #     - org.apache.struts
  #     # Dependency Full Name (manager + name + version)
  #     - maven://org.apache.struts#2.0.5
  # warnings:
  #   ids:
  #     # Other is the 'Known Licensing' in GitHub Dependency Graph
  #     - Other
  #     # NA or Not Available is where the GitHub Dependency Graph has no data 
  #     #  on the repository
  #     - NA
  # # Ignores are run next so if an ignored rule is hit that matches the level, it will be skipped
  # ignores:
  #   ids:
  #     - MIT License

# ------------ #

secretscanning:
  level: all
  remediate:
    # All secrets by default are set to 'critical' severity so only `critical` 
    #  or `all` will work
    critical: 3

Version

v2 (current major version)

Where are you experiencing the issue?

GitHub Actions

Relevant log output

2024-06-06T18:45:53.3906058Z Current runner version: '2.317.0'
2024-06-06T18:45:53.3929208Z ##[group]Operating System
2024-06-06T18:45:53.3929815Z Ubuntu
2024-06-06T18:45:53.3930275Z 22.04.4
2024-06-06T18:45:53.3930597Z LTS
2024-06-06T18:45:53.3930908Z ##[endgroup]
2024-06-06T18:45:53.3931356Z ##[group]Runner Image
2024-06-06T18:45:53.3931788Z Image: ubuntu-22.04
2024-06-06T18:45:53.3932205Z Version: 20240603.1.0
2024-06-06T18:45:53.3933229Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240603.1/images/ubuntu/Ubuntu2204-Readme.md
2024-06-06T18:45:53.3934670Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240603.1
2024-06-06T18:45:53.3935526Z ##[endgroup]
2024-06-06T18:45:53.3936007Z ##[group]Runner Image Provisioner
2024-06-06T18:45:53.3936468Z 2.0.370.1
2024-06-06T18:45:53.3936797Z ##[endgroup]
2024-06-06T18:45:53.3937984Z ##[group]GITHUB_TOKEN Permissions
2024-06-06T18:45:53.3939518Z Contents: read
2024-06-06T18:45:53.3940053Z Metadata: read
2024-06-06T18:45:53.3940635Z PullRequests: write
2024-06-06T18:45:53.3941214Z SecurityEvents: read
2024-06-06T18:45:53.3941621Z ##[endgroup]
2024-06-06T18:45:53.3943737Z Secret source: Actions
2024-06-06T18:45:53.3944470Z Prepare workflow directory
2024-06-06T18:45:53.4657177Z Prepare all required actions
2024-06-06T18:45:53.4814468Z Getting action download info
2024-06-06T18:45:53.6694692Z Download action repository 'advanced-security/[email protected]' (SHA:70331f3a4dd481cefa98f5341250ac3dea2a8d5f)
2024-06-06T18:45:54.2543433Z Complete job name: Policy Testing
2024-06-06T18:45:54.3710095Z ##[group]Run advanced-security/[email protected]
2024-06-06T18:45:54.3711195Z with:
2024-06-06T18:45:54.3712044Z   policy: ********/ghas-policy-as-code
2024-06-06T18:45:54.3713239Z   policy-path: policies/default.yml
2024-06-06T18:45:54.3714127Z   policy-branch: main
2024-06-06T18:45:54.3715927Z   policy-repo-token: ***
2024-06-06T18:45:54.3716910Z   argvs: --display --pr-comment
2024-06-06T18:45:54.3717640Z   severity: error
2024-06-06T18:45:54.3718482Z   repository: ********/vera-busted-01
2024-06-06T18:45:54.3719921Z   token: ***
2024-06-06T18:45:54.3720555Z   ref: refs/heads/main
2024-06-06T18:45:54.3721188Z   action: break
2024-06-06T18:45:54.3722072Z ##[endgroup]
2024-06-06T18:45:54.4118916Z ##[group]Run echo "Running Policy as Code..."
2024-06-06T18:45:54.4120122Z �[36;1mecho "Running Policy as Code..."�[0m
2024-06-06T18:45:54.4122904Z �[36;1mexport PYTHONPATH=/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3:/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3/vendor�[0m
2024-06-06T18:45:54.4125384Z �[36;1mpython3 -m ghascompliance \�[0m
2024-06-06T18:45:54.4126297Z �[36;1m  --severity "error" \�[0m
2024-06-06T18:45:54.4127678Z �[36;1m  --action "break" \�[0m
2024-06-06T18:45:54.4128971Z �[36;1m  --github-token "***" \�[0m
2024-06-06T18:45:54.4131149Z �[36;1m  --policy-repo-token "***" \�[0m
2024-06-06T18:45:54.4132730Z �[36;1m  --github-repository "********/vera-busted-01" \�[0m
2024-06-06T18:45:54.4134130Z �[36;1m  --github-ref "refs/heads/main" \�[0m
2024-06-06T18:45:54.4135712Z �[36;1m  --github-policy "********/ghas-policy-as-code" \�[0m
2024-06-06T18:45:54.4137266Z �[36;1m  --github-policy-path "policies/default.yml" \�[0m
2024-06-06T18:45:54.4138464Z �[36;1m  --github-policy-branch "main" \�[0m
2024-06-06T18:45:54.4139624Z �[36;1m  --display --pr-comment�[0m
2024-06-06T18:45:54.4252529Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2024-06-06T18:45:54.4253921Z ##[endgroup]
2024-06-06T18:45:54.4817277Z Running Policy as Code...
2024-06-06T18:45:54.7343211Z INFO:root:GitHub Repository :: ********/vera-busted-01
2024-06-06T18:45:54.7344596Z INFO:root:GitHub Instance :: https://github.com
2024-06-06T18:45:54.7345546Z INFO:root:GitHub Reference (branch/pr) :: refs/heads/main
2024-06-06T18:45:54.7347607Z INFO:root:Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-06T18:45:54.7350039Z INFO:root:Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-06T18:45:55.2202491Z INFO:root:Loading policy file - /tmp/repo/policies/default.yml
2024-06-06T18:45:55.2232103Z INFO:root:Enabling Time to Remediate (global) :: codescanning
2024-06-06T18:45:55.2234071Z INFO:root:Policy loaded successfully
2024-06-06T18:45:55.2236323Z INFO:root:Saving Policy...
2024-06-06T18:45:55.2237727Z INFO:root:Policy saved
2024-06-06T18:45:55.2239375Z INFO:root:Finished loading policy
2024-06-06T18:45:55.2240988Z INFO:root:Policy as Code Summary:
2024-06-06T18:45:55.2242723Z INFO:root:
2024-06-06T18:45:55.2244014Z INFO:root:general: 'error'
2024-06-06T18:45:55.2245952Z INFO:root:codescanning: 'error'
2024-06-06T18:45:55.2248061Z INFO:root:dependabot: 'None'
2024-06-06T18:45:55.2250579Z INFO:root:secretscanning: 'all'
2024-06-06T18:45:55.2251796Z INFO:root:licensing: 'error'
2024-06-06T18:45:55.2252848Z INFO:root:dependencies: 'error'
2024-06-06T18:45:55.2253802Z INFO:root:```
2024-06-06T18:45:55.4187270Z INFO:root:Total Code Scanning Alerts :: 1
2024-06-06T18:45:55.4232552Z ERROR:root:CodeQL - 2023-10-30 20:34:07 - Inefficient regular expression
2024-06-06T18:45:55.4233934Z  _____  _   _   ___   _____ _____                       _ _                      
2024-06-06T18:45:55.4234812Z |  __ \| | | | / _ \ /  ___/  __ \                     | (_)                     
2024-06-06T18:45:55.4235746Z | |  \/| |_| |/ /_\ \\ `--.| /  \/ ___  _ __ ___  _ __ | |_  __ _ _ __   ___ ___ 
2024-06-06T18:45:55.4237084Z | | __ |  _  ||  _  | `--. \ |    / _ \| '_ ` _ \| '_ \| | |/ _` | '_ \ / __/ _ \
2024-06-06T18:45:55.4237935Z | |_\ \| | | || | | |/\__/ / \__/\ (_) | | | | | | |_) | | | (_| | | | | (_|  __/
2024-06-06T18:45:55.4238783Z  \____/\_| |_/\_| |_/\____/ \____/\___/|_| |_| |_| .__/|_|_|\__,_|_| |_|\___\___|
2024-06-06T18:45:55.4239664Z                                                  | |                             
2024-06-06T18:45:55.4240360Z                                                  |_|         v2.7.3
2024-06-06T18:45:55.4241095Z     GitHub Advanced Security Policy as Code by GeekMasher
2024-06-06T18:45:55.4241757Z 
2024-06-06T18:45:55.4242196Z GitHub Repository :: ********/vera-busted-01
2024-06-06T18:45:55.4243016Z GitHub Instance :: https://github.com
2024-06-06T18:45:55.4243889Z GitHub Reference (branch/pr) :: refs/heads/main
2024-06-06T18:45:55.4253576Z ##[group]Policy as Code
2024-06-06T18:45:55.4255025Z Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-06T18:45:55.4256790Z Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-06T18:45:55.4257759Z Loading policy file - /tmp/repo/policies/default.yml
2024-06-06T18:45:55.4258538Z Enabling Time to Remediate (global) :: codescanning
2024-06-06T18:45:55.4259295Z Policy loaded successfully
2024-06-06T18:45:55.4259766Z Saving Policy...
2024-06-06T18:45:55.4260141Z Policy saved
2024-06-06T18:45:55.4260613Z Finished loading policy
2024-06-06T18:45:55.4261071Z Policy as Code Summary:
2024-06-06T18:45:55.4261472Z ```
2024-06-06T18:45:55.4261945Z general: 'error'
2024-06-06T18:45:55.4262597Z codescanning: 'error'
2024-06-06T18:45:55.4263271Z dependabot: 'None'
2024-06-06T18:45:55.4263706Z secretscanning: 'all'
2024-06-06T18:45:55.4264165Z licensing: 'error'
2024-06-06T18:45:55.4264696Z dependencies: 'error'
2024-06-06T18:45:55.4265078Z ```
2024-06-06T18:45:55.4265902Z ##[endgroup]
2024-06-06T18:45:55.4266777Z ##[group]Code Scanning Results
2024-06-06T18:45:55.4267297Z Total Code Scanning Alerts :: 1
2024-06-06T18:45:55.4290395Z ##[error]CodeQL - 2023-10-30 20:34:07 - Inefficient regular expression
2024-06-06T18:45:55.4291962Z INFO:root:Code Scanning violations :: 1
2024-06-06T18:45:55.5676155Z ERROR:ghastoolkit.octokit:Error code from server :: 403
2024-06-06T18:45:55.5678339Z ERROR:ghastoolkit.octokit:Error message from server :: Resource not accessible by integration
2024-06-06T18:45:55.5682553Z ERROR:ghastoolkit.octokit:Documentation Link :: https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository
2024-06-06T18:45:55.5685735Z WARNING:root:Unable to get Dependabot alerts :: REST Request failed :: Resource not accessible by integration
2024-06-06T18:45:55.5687445Z WARNING:root:Trying GraphQL API
2024-06-06T18:46:05.9961554Z INFO:root:Total Dependabot Alerts :: 0
2024-06-06T18:46:05.9963267Z INFO:root:Dependabot violations :: 0
2024-06-06T18:46:15.6697647Z INFO:root:Total Dependency Graph :: 828
2024-06-06T18:46:15.6764186Z INFO:root:Dependency Graph violations :: 0
2024-06-06T18:46:26.5965129Z ERROR:ghastoolkit.octokit:GraphQL API Status :: 502
2024-06-06T18:46:26.5969365Z ERROR:ghastoolkit.octokit:GraphQL Content :: b'{\n   "data": null,\n   "errors":[\n      {\n         "message":"Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include `A4D3:360A1:447E699:78AAC10:666203F8` when reporting this issue."\n      }\n   ]\n}\n'
2024-06-06T18:46:26.5974152Z ERROR:root:Unknown Exception was hit, please repo this to https://github.com/advanced-security/policy-as-code
2024-06-06T18:46:26.5975415Z ERROR:root:Failed to get data from GraphQL API
2024-06-06T18:46:26.5977438Z Code Scanning violations :: 1
2024-06-06T18:46:26.5978802Z ##[endgroup]
2024-06-06T18:46:26.5979760Z ##[group]Dependabot Results
2024-06-06T18:46:26.5984124Z ##[warning] Unable to get Dependabot alerts :: REST Request failed :: Resource not accessible by integration
2024-06-06T18:46:26.5986508Z ##[warning] Trying GraphQL API
2024-06-06T18:46:26.5987140Z Total Dependabot Alerts :: 0
2024-06-06T18:46:26.5988066Z Dependabot violations :: 0
2024-06-06T18:46:26.5989130Z ##[endgroup]
2024-06-06T18:46:26.5990122Z ##[group]Dependency Graph
2024-06-06T18:46:26.5990728Z Total Dependency Graph :: 828
2024-06-06T18:46:26.5991304Z Dependency Graph violations :: 0
2024-06-06T18:46:26.5992350Z ##[endgroup]
2024-06-06T18:46:26.5993401Z ##[group]Dependency Graph Results - Licensing
2024-06-06T18:46:26.5996462Z ##[error]Unknown Exception was hit, please repo this to https://github.com/advanced-security/policy-as-code
2024-06-06T18:46:26.5998992Z ##[error]Failed to get data from GraphQL API
2024-06-06T18:46:26.8157408Z INFO:root:Total unacceptable alerts :: 3
2024-06-06T18:46:26.8158672Z ERROR:root:Unacceptable Threshold of Risk has been hit!
2024-06-06T18:46:26.8160247Z ##[group]Secret Scanning Results
2024-06-06T18:46:26.8161370Z ##[endgroup]
2024-06-06T18:46:26.8162138Z ##[group]Summary
2024-06-06T18:46:26.8162751Z Total unacceptable alerts :: 3
2024-06-06T18:46:26.8164446Z ##[error]Unacceptable Threshold of Risk has been hit!
2024-06-06T18:46:26.8343905Z ##[error]Process completed with exit code 1.
2024-06-06T18:46:26.8644825Z Cleaning up orphan processes

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Brutalbeard Brutalbeard added the bug Something isn't working label Jun 6, 2024
@Brutalbeard
Copy link
Author

Also worth calling out, the above was from running directly against a Push to main. Here's a PR to main:
Screenshot 2024-06-06 at 3 04 41 PM

And the logs which did show errors, though they didn't show up in the PR comment:

2024-06-06T21:01:18.0645933Z ##[group]Operating System
2024-06-06T21:01:18.0646731Z Ubuntu
2024-06-06T21:01:18.0647121Z 22.04.4
2024-06-06T21:01:18.0647524Z LTS
2024-06-06T21:01:18.0647833Z ##[endgroup]
2024-06-06T21:01:18.0648436Z ##[group]Runner Image
2024-06-06T21:01:18.0649008Z Image: ubuntu-22.04
2024-06-06T21:01:18.0649392Z Version: 20240603.1.0
2024-06-06T21:01:18.0650431Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240603.1/images/ubuntu/Ubuntu2204-Readme.md
2024-06-06T21:01:18.0651984Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240603.1
2024-06-06T21:01:18.0652892Z ##[endgroup]
2024-06-06T21:01:18.0653255Z ##[group]Runner Image Provisioner
2024-06-06T21:01:18.0653819Z 2.0.370.1
2024-06-06T21:01:18.0654206Z ##[endgroup]
2024-06-06T21:01:18.0655381Z ##[group]GITHUB_TOKEN Permissions
2024-06-06T21:01:18.0657160Z Contents: read
2024-06-06T21:01:18.0657605Z Metadata: read
2024-06-06T21:01:18.0658332Z PullRequests: write
2024-06-06T21:01:18.0658838Z SecurityEvents: read
2024-06-06T21:01:18.0659400Z ##[endgroup]
2024-06-06T21:01:18.0661505Z Secret source: Actions
2024-06-06T21:01:18.0662116Z Prepare workflow directory
2024-06-06T21:01:18.1286311Z Prepare all required actions
2024-06-06T21:01:18.1442730Z Getting action download info
2024-06-06T21:01:18.2818246Z Download action repository 'advanced-security/[email protected]' (SHA:70331f3a4dd481cefa98f5341250ac3dea2a8d5f)
2024-06-06T21:01:18.9050398Z Complete job name: Policy Testing
2024-06-06T21:01:19.0228835Z ##[group]Run advanced-security/[email protected]
2024-06-06T21:01:19.0229957Z with:
2024-06-06T21:01:19.0231023Z   policy: ********/ghas-policy-as-code
2024-06-06T21:01:19.0232164Z   policy-path: policies/default.yml
2024-06-06T21:01:19.0233125Z   policy-branch: main
2024-06-06T21:01:19.0235254Z   policy-repo-token: ***
2024-06-06T21:01:19.0236135Z   argvs: --display --pr-comment
2024-06-06T21:01:19.0237201Z   severity: error
2024-06-06T21:01:19.0238174Z   repository: ********/vera-busted-01
2024-06-06T21:01:19.0239564Z   token: ***
2024-06-06T21:01:19.0240394Z   ref: refs/pull/100/merge
2024-06-06T21:01:19.0241112Z   action: break
2024-06-06T21:01:19.0241837Z ##[endgroup]
2024-06-06T21:01:19.0635665Z ##[group]Run echo "Running Policy as Code..."
2024-06-06T21:01:19.0636895Z �[36;1mecho "Running Policy as Code..."�[0m
2024-06-06T21:01:19.0639879Z �[36;1mexport PYTHONPATH=/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3:/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3/vendor�[0m
2024-06-06T21:01:19.0642429Z �[36;1mpython3 -m ghascompliance \�[0m
2024-06-06T21:01:19.0643598Z �[36;1m  --severity "error" \�[0m
2024-06-06T21:01:19.0644556Z �[36;1m  --action "break" \�[0m
2024-06-06T21:01:19.0645991Z �[36;1m  --github-token "***" \�[0m
2024-06-06T21:01:19.0648725Z �[36;1m  --policy-repo-token "***" \�[0m
2024-06-06T21:01:19.0650121Z �[36;1m  --github-repository "********/vera-busted-01" \�[0m
2024-06-06T21:01:19.0651577Z �[36;1m  --github-ref "refs/pull/100/merge" \�[0m
2024-06-06T21:01:19.0653208Z �[36;1m  --github-policy "********/ghas-policy-as-code" \�[0m
2024-06-06T21:01:19.0654803Z �[36;1m  --github-policy-path "policies/default.yml" \�[0m
2024-06-06T21:01:19.0656049Z �[36;1m  --github-policy-branch "main" \�[0m
2024-06-06T21:01:19.0657254Z �[36;1m  --display --pr-comment�[0m
2024-06-06T21:01:19.0769040Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2024-06-06T21:01:19.0770447Z ##[endgroup]
2024-06-06T21:01:19.1132318Z Running Policy as Code...
2024-06-06T21:01:19.4175147Z INFO:root:GitHub Repository :: ********/vera-busted-01
2024-06-06T21:01:19.4176495Z INFO:root:GitHub Instance :: https://github.com
2024-06-06T21:01:19.4177739Z INFO:root:GitHub Reference (branch/pr) :: refs/pull/100/merge
2024-06-06T21:01:19.4179324Z INFO:root:Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-06T21:01:19.4181754Z INFO:root:Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-06T21:01:19.9127643Z INFO:root:Loading policy file - /tmp/repo/policies/default.yml
2024-06-06T21:01:19.9129738Z INFO:root:Enabling Time to Remediate (global) :: codescanning
2024-06-06T21:01:19.9131277Z INFO:root:Policy loaded successfully
2024-06-06T21:01:19.9132528Z INFO:root:Saving Policy...
2024-06-06T21:01:19.9133502Z INFO:root:Policy saved
2024-06-06T21:01:19.9134598Z INFO:root:Finished loading policy
2024-06-06T21:01:19.9135585Z INFO:root:Policy as Code Summary:
2024-06-06T21:01:19.9136795Z INFO:root:```
2024-06-06T21:01:19.9137779Z INFO:root:general: 'error'
2024-06-06T21:01:19.9138862Z INFO:root:codescanning: 'error'
2024-06-06T21:01:19.9140063Z INFO:root:dependabot: 'None'
2024-06-06T21:01:19.9141367Z INFO:root:secretscanning: 'all'
2024-06-06T21:01:19.9142505Z INFO:root:licensing: 'error'
2024-06-06T21:01:19.9143765Z INFO:root:dependencies: 'error'
2024-06-06T21:01:19.9144568Z INFO:root:```
2024-06-06T21:01:19.9145463Z INFO:root:Code Scanning Alerts from Pull Request (alert diff)
2024-06-06T21:01:20.5919271Z INFO:root:Total Code Scanning Alerts :: 0
2024-06-06T21:01:20.5920165Z INFO:root:Code Scanning violations :: 0
2024-06-06T21:01:20.5921141Z INFO:root:Dependabot Alerts from Pull Request
2024-06-06T21:01:20.8783609Z WARNING:ghastoolkit.octokit.dependencygraph:Failed to get dependencies from Pull Request
2024-06-06T21:01:20.8785808Z WARNING:ghastoolkit.octokit.dependencygraph:Make sure Advanced Security is enabled and token permissions are correct
2024-06-06T21:01:20.8787227Z INFO:root:Total Dependabot Alerts :: 0
2024-06-06T21:01:20.8788023Z INFO:root:Dependabot violations :: 0
2024-06-06T21:01:20.8794187Z INFO:root:Dependencies from Pull Request
2024-06-06T21:01:21.0944357Z WARNING:ghastoolkit.octokit.dependencygraph:Failed to get dependencies from Pull Request
2024-06-06T21:01:21.0946912Z WARNING:ghastoolkit.octokit.dependencygraph:Make sure Advanced Security is enabled and token permissions are correct
2024-06-06T21:01:21.0949051Z INFO:root:Total Dependency Graph :: 0
2024-06-06T21:01:21.0950268Z INFO:root:Dependency Graph violations :: 0
2024-06-06T21:01:21.0956104Z INFO:root:Dependencies from Pull Request
2024-06-06T21:01:21.2505744Z WARNING:ghastoolkit.octokit.dependencygraph:Failed to get dependencies from Pull Request
2024-06-06T21:01:21.2513117Z WARNING:ghastoolkit.octokit.dependencygraph:Make sure Advanced Security is enabled and token permissions are correct
2024-06-06T21:01:21.2562379Z INFO:root:Loaded extra licensing information :: 9459
2024-06-06T21:01:21.2563969Z INFO:root:Total Dependencies in Graph :: 0
2024-06-06T21:01:21.2565366Z INFO:root:Dependency Graph violations :: 0
2024-06-06T21:01:21.6930414Z INFO:root:No exisiting comment from PaC, adding a new comment...
2024-06-06T21:01:22.2136460Z INFO:root:Total unacceptable alerts :: 1
2024-06-06T21:01:22.2143174Z ERROR:root:Unacceptable Threshold of Risk has been hit!
2024-06-06T21:01:22.2144088Z  _____  _   _   ___   _____ _____                       _ _                      
2024-06-06T21:01:22.2145485Z |  __ \| | | | / _ \ /  ___/  __ \                     | (_)                     
2024-06-06T21:01:22.2147355Z | |  \/| |_| |/ /_\ \\ `--.| /  \/ ___  _ __ ___  _ __ | |_  __ _ _ __   ___ ___ 
2024-06-06T21:01:22.2148596Z | | __ |  _  ||  _  | `--. \ |    / _ \| '_ ` _ \| '_ \| | |/ _` | '_ \ / __/ _ \
2024-06-06T21:01:22.2150108Z | |_\ \| | | || | | |/\__/ / \__/\ (_) | | | | | | |_) | | | (_| | | | | (_|  __/
2024-06-06T21:01:22.2151402Z  \____/\_| |_/\_| |_/\____/ \____/\___/|_| |_| |_| .__/|_|_|\__,_|_| |_|\___\___|
2024-06-06T21:01:22.2152832Z                                                  | |                             
2024-06-06T21:01:22.2154973Z                                                  |_|         v2.7.3
2024-06-06T21:01:22.2155838Z     GitHub Advanced Security Policy as Code by GeekMasher
2024-06-06T21:01:22.2156365Z 
2024-06-06T21:01:22.2157046Z GitHub Repository :: ********/vera-busted-01
2024-06-06T21:01:22.2158277Z GitHub Instance :: https://github.com
2024-06-06T21:01:22.2159056Z GitHub Reference (branch/pr) :: refs/pull/100/merge
2024-06-06T21:01:22.2172540Z ##[group]Policy as Code
2024-06-06T21:01:22.2174004Z Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-06T21:01:22.2175821Z Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-06T21:01:22.2176995Z Loading policy file - /tmp/repo/policies/default.yml
2024-06-06T21:01:22.2177846Z Enabling Time to Remediate (global) :: codescanning
2024-06-06T21:01:22.2178719Z Policy loaded successfully
2024-06-06T21:01:22.2179294Z Saving Policy...
2024-06-06T21:01:22.2179749Z Policy saved
2024-06-06T21:01:22.2180375Z Finished loading policy
2024-06-06T21:01:22.2180946Z Policy as Code Summary:
2024-06-06T21:01:22.2181460Z ```
2024-06-06T21:01:22.2182067Z general: 'error'
2024-06-06T21:01:22.2182645Z codescanning: 'error'
2024-06-06T21:01:22.2183262Z dependabot: 'None'
2024-06-06T21:01:22.2183951Z secretscanning: 'all'
2024-06-06T21:01:22.2184549Z licensing: 'error'
2024-06-06T21:01:22.2185162Z dependencies: 'error'
2024-06-06T21:01:22.2185890Z ```
2024-06-06T21:01:22.2186877Z ##[endgroup]
2024-06-06T21:01:22.2188019Z ##[group]Code Scanning Results
2024-06-06T21:01:22.2188808Z Code Scanning Alerts from Pull Request (alert diff)
2024-06-06T21:01:22.2189602Z Total Code Scanning Alerts :: 0
2024-06-06T21:01:22.2190673Z Code Scanning violations :: 0
2024-06-06T21:01:22.2191562Z ##[endgroup]
2024-06-06T21:01:22.2192392Z ##[group]Dependabot Results
2024-06-06T21:01:22.2192994Z Dependabot Alerts from Pull Request
2024-06-06T21:01:22.2193639Z Total Dependabot Alerts :: 0
2024-06-06T21:01:22.2194323Z Dependabot violations :: 0
2024-06-06T21:01:22.2195278Z ##[endgroup]
2024-06-06T21:01:22.2196202Z ##[group]Dependency Graph
2024-06-06T21:01:22.2196999Z Dependencies from Pull Request
2024-06-06T21:01:22.2197668Z Total Dependency Graph :: 0
2024-06-06T21:01:22.2198476Z Dependency Graph violations :: 0
2024-06-06T21:01:22.2199501Z ##[endgroup]
2024-06-06T21:01:22.2200703Z ##[group]Dependency Graph Results - Licensing
2024-06-06T21:01:22.2201494Z Dependencies from Pull Request
2024-06-06T21:01:22.2202176Z Loaded extra licensing information :: 9459
2024-06-06T21:01:22.2203103Z Total Dependencies in Graph :: 0
2024-06-06T21:01:22.2203814Z Dependency Graph violations :: 0
2024-06-06T21:01:22.2204967Z ##[endgroup]
2024-06-06T21:01:22.2205878Z ##[group]Secret Scanning Results
2024-06-06T21:01:22.2206987Z ##[endgroup]
2024-06-06T21:01:22.2207797Z ##[group]Summary
2024-06-06T21:01:22.2209308Z ##[group]Pull Request comment
2024-06-06T21:01:22.2210024Z No exisiting comment from PaC, adding a new comment...
2024-06-06T21:01:22.2211325Z ##[endgroup]
2024-06-06T21:01:22.2211882Z Total unacceptable alerts :: 1
2024-06-06T21:01:22.2242834Z ##[error]Unacceptable Threshold of Risk has been hit!
2024-06-06T21:01:22.2333189Z ##[error]Process completed with exit code 1.
2024-06-06T21:01:22.2623830Z Cleaning up orphan processes

This one is really difficult to figure out for me. The individual log lines show no issues, but then the action fails saying 'Total unacceptable alerts :: 1`. So the action fails, blocking the merge, but no info given in the comment as to why. And of course not consistent with the results originally added to this Issue

@Brutalbeard
Copy link
Author

I mean it obviously says it failed its API calls, but this is the same workflow that ran on the push to main, so it's not clear why that was the case

@GeekMasher
Copy link
Collaborator

@Brutalbeard this might be an issue with the token permissions. Secret Scanning API might not be accessible via the normal Actions tokens.

You can fix this by using and setting up a GitHub App + using this action from one of my colleagues:

https://github.com/peter-murray/workflow-application-token-action

You'll have to set the policy-as-code token to the output of the application token action

A similar example can be found here

https://github.com/advanced-security/policy-as-code/blob/main/examples/workflows/appAuth.yml

@Brutalbeard
Copy link
Author

Testing complete, but still not happy. Not seeing any issue pulling info, and in logs it seems to be finding some issues, but nothing in the comments on PRs. Would think there'd be a link directly to the violating alert of each type? At least a count?

I created an app with the following permissions:

  • Actions - Read Only
  • Code scanning alerts - Read Only
  • Contents - Read Only
  • Custom properties - Read Only (may be using this at some point)
  • Dependabot alerts - Read Only
  • Metadata - Read Only
  • Pull requests - Read/Write
  • Repository security advisories - Read Only
  • Secret scanning alerts - Read Only

Updated workflow file:

name: Policy Testing - No General Workflow

on:
    pull_request:
        branches: main
    push:
        branches: main

jobs:
    policy-check:
        runs-on: ubuntu-latest
        name: Policy Testing

        steps:
            - name: Get Token
              id: get_workflow_token
              uses: peter-murray/workflow-application-token-action@v3
              with:
                  application_id: ${{ secrets.GHAS_APPLICATION_ID }}
                  application_private_key: ${{ secrets.GHAS_APPLICATION_PRIVATE_KEY }}

            # Compliance
            - name: Advance Security Policy as Code
              uses: advanced-security/[email protected]
              with:
                  token: ${{ steps.get_workflow_token.outputs.token }}
                  # The owner/repo of where the policy is stored
                  policy: dat-freight-and-analytics/ghas-policy-as-code
                  # The local (within the workspace) or repository
                  policy-path: policies/default.yml
                  # The branch you want to target
                  policy-branch: main
                  policy-repo-token: ${{ secrets.GHAS_COMPLIANCE_PAT }}
                  argvs: "--display --pr-comment --is-github-app-token"

Results:

PR Logs:

2024-06-07T19:17:48.7373199Z Current runner version: '2.317.0'
2024-06-07T19:17:48.7397894Z ##[group]Operating System
2024-06-07T19:17:48.7398775Z Ubuntu
2024-06-07T19:17:48.7399427Z 22.04.4
2024-06-07T19:17:48.7400017Z LTS
2024-06-07T19:17:48.7400571Z ##[endgroup]
2024-06-07T19:17:48.7401229Z ##[group]Runner Image
2024-06-07T19:17:48.7401965Z Image: ubuntu-22.04
2024-06-07T19:17:48.7402567Z Version: 20240603.1.0
2024-06-07T19:17:48.7404074Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240603.1/images/ubuntu/Ubuntu2204-Readme.md
2024-06-07T19:17:48.7406073Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240603.1
2024-06-07T19:17:48.7407359Z ##[endgroup]
2024-06-07T19:17:48.7408039Z ##[group]Runner Image Provisioner
2024-06-07T19:17:48.7408771Z 2.0.370.1
2024-06-07T19:17:48.7409415Z ##[endgroup]
2024-06-07T19:17:48.7412956Z ##[group]GITHUB_TOKEN Permissions
2024-06-07T19:17:48.7414886Z Actions: write
2024-06-07T19:17:48.7415851Z Attestations: write
2024-06-07T19:17:48.7416602Z Checks: write
2024-06-07T19:17:48.7417286Z Contents: write
2024-06-07T19:17:48.7417901Z Deployments: write
2024-06-07T19:17:48.7418593Z Discussions: write
2024-06-07T19:17:48.7419270Z Issues: write
2024-06-07T19:17:48.7419854Z Metadata: read
2024-06-07T19:17:48.7420515Z Packages: write
2024-06-07T19:17:48.7421137Z Pages: write
2024-06-07T19:17:48.7421795Z PullRequests: write
2024-06-07T19:17:48.7422493Z RepositoryProjects: write
2024-06-07T19:17:48.7423523Z SecurityEvents: write
2024-06-07T19:17:48.7424297Z Statuses: write
2024-06-07T19:17:48.7424960Z ##[endgroup]
2024-06-07T19:17:48.7427479Z Secret source: Actions
2024-06-07T19:17:48.7428455Z Prepare workflow directory
2024-06-07T19:17:48.8049498Z Prepare all required actions
2024-06-07T19:17:48.8206468Z Getting action download info
2024-06-07T19:17:48.9492177Z Download action repository 'peter-murray/workflow-application-token-action@v3' (SHA:dc0413987a085fa17d19df9e47d4677cf81ffef3)
2024-06-07T19:17:49.3092927Z Download action repository 'advanced-security/[email protected]' (SHA:70331f3a4dd481cefa98f5341250ac3dea2a8d5f)
2024-06-07T19:17:49.7811062Z Complete job name: Policy Testing
2024-06-07T19:17:49.8809345Z ##[group]Run peter-murray/workflow-application-token-action@v3
2024-06-07T19:17:49.8810242Z with:
2024-06-07T19:17:49.8810759Z   application_id: ***
2024-06-07T19:17:49.8826764Z   application_private_key: ***
2024-06-07T19:17:49.8827371Z   revoke_token: false
2024-06-07T19:17:49.8827842Z ##[endgroup]
2024-06-07T19:17:50.1691350Z Found GitHub Application: GHAS-Policy-as-Code
2024-06-07T19:17:50.1694658Z Obtaining application installation for repository: ********/vera-busted-01
2024-06-07T19:17:50.3214813Z {"token":"***","expires_at":"2024-06-07T20:17:50Z","permissions":{"actions":"read","contents":"read","metadata":"read","pull_requests":"write","repository_advisories":"read","repository_custom_properties":"read","secret_scanning_alerts":"read","security_events":"read","vulnerability_alerts":"read"},"repository_selection":"selected"}
2024-06-07T19:17:50.3218774Z Successfully generated an access token for application.
2024-06-07T19:17:50.3492894Z ##[group]Run advanced-security/[email protected]
2024-06-07T19:17:50.3493670Z with:
2024-06-07T19:17:50.3494300Z   token: ***
2024-06-07T19:17:50.3494903Z   policy: ********/ghas-policy-as-code
2024-06-07T19:17:50.3495689Z   policy-path: policies/default.yml
2024-06-07T19:17:50.3496288Z   policy-branch: main
2024-06-07T19:17:50.3497497Z   policy-repo-token: ***
2024-06-07T19:17:50.3498135Z   argvs: --display --pr-comment --is-github-app-token
2024-06-07T19:17:50.3498862Z   severity: error
2024-06-07T19:17:50.3499440Z   repository: ********/vera-busted-01
2024-06-07T19:17:50.3500192Z   ref: refs/pull/100/merge
2024-06-07T19:17:50.3500701Z   action: break
2024-06-07T19:17:50.3501135Z ##[endgroup]
2024-06-07T19:17:50.3761337Z ##[group]Run echo "Running Policy as Code..."
2024-06-07T19:17:50.3762156Z �[36;1mecho "Running Policy as Code..."�[0m
2024-06-07T19:17:50.3764233Z �[36;1mexport PYTHONPATH=/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3:/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3/vendor�[0m
2024-06-07T19:17:50.3765938Z �[36;1mpython3 -m ghascompliance \�[0m
2024-06-07T19:17:50.3766581Z �[36;1m  --severity "error" \�[0m
2024-06-07T19:17:50.3767144Z �[36;1m  --action "break" \�[0m
2024-06-07T19:17:50.3768089Z �[36;1m  --github-token "***" \�[0m
2024-06-07T19:17:50.3769516Z �[36;1m  --policy-repo-token "***" \�[0m
2024-06-07T19:17:50.3770437Z �[36;1m  --github-repository "********/vera-busted-01" \�[0m
2024-06-07T19:17:50.3771432Z �[36;1m  --github-ref "refs/pull/100/merge" \�[0m
2024-06-07T19:17:50.3772393Z �[36;1m  --github-policy "********/ghas-policy-as-code" \�[0m
2024-06-07T19:17:50.3773446Z �[36;1m  --github-policy-path "policies/default.yml" \�[0m
2024-06-07T19:17:50.3774262Z �[36;1m  --github-policy-branch "main" \�[0m
2024-06-07T19:17:50.3775052Z �[36;1m  --display --pr-comment --is-github-app-token�[0m
2024-06-07T19:17:50.3850083Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2024-06-07T19:17:50.3850907Z ##[endgroup]
2024-06-07T19:17:50.4008351Z Running Policy as Code...
2024-06-07T19:17:50.6520806Z INFO:root:GitHub Repository :: ********/vera-busted-01
2024-06-07T19:17:50.6535755Z INFO:root:GitHub Instance :: https://github.com
2024-06-07T19:17:50.6537557Z INFO:root:GitHub Reference (branch/pr) :: refs/pull/100/merge
2024-06-07T19:17:50.6540799Z INFO:root:Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-07T19:17:50.6544182Z INFO:root:Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-07T19:17:51.0965400Z INFO:root:Loading policy file - /tmp/repo/policies/default.yml
2024-06-07T19:17:51.0967174Z INFO:root:Enabling Time to Remediate (global) :: codescanning
2024-06-07T19:17:51.0968624Z INFO:root:Policy loaded successfully
2024-06-07T19:17:51.0969816Z INFO:root:Saving Policy...
2024-06-07T19:17:51.0970844Z INFO:root:Policy saved
2024-06-07T19:17:51.0971846Z INFO:root:Finished loading policy
2024-06-07T19:17:51.0972960Z INFO:root:Policy as Code Summary:
2024-06-07T19:17:51.0974294Z INFO:root:```
2024-06-07T19:17:51.0975284Z INFO:root:general: 'error'
2024-06-07T19:17:51.0976435Z INFO:root:codescanning: 'error'
2024-06-07T19:17:51.0977638Z INFO:root:dependabot: 'None'
2024-06-07T19:17:51.0978776Z INFO:root:secretscanning: 'all'
2024-06-07T19:17:51.0979897Z INFO:root:licensing: 'error'
2024-06-07T19:17:51.0981036Z INFO:root:dependencies: 'error'
2024-06-07T19:17:51.0982102Z INFO:root:```
2024-06-07T19:17:51.0984510Z INFO:root:Code Scanning Alerts from Pull Request (alert diff)
2024-06-07T19:17:51.6913342Z INFO:root:Total Code Scanning Alerts :: 0
2024-06-07T19:17:51.6914378Z INFO:root:Code Scanning violations :: 0
2024-06-07T19:17:51.6915336Z INFO:root:Dependabot Alerts from Pull Request
2024-06-07T19:17:52.0051375Z INFO:root:Total Dependabot Alerts :: 0
2024-06-07T19:17:52.0052640Z INFO:root:Dependabot violations :: 0
2024-06-07T19:17:52.0054064Z INFO:root:Dependencies from Pull Request
2024-06-07T19:17:52.1224153Z INFO:root:Total Dependency Graph :: 1
2024-06-07T19:17:52.1225197Z INFO:root:Dependency Graph violations :: 0
2024-06-07T19:17:52.1226115Z INFO:root:Dependencies from Pull Request
2024-06-07T19:17:52.2890834Z INFO:root:Loaded extra licensing information :: 9459
2024-06-07T19:17:52.2892473Z INFO:root:Total Dependencies in Graph :: 1
2024-06-07T19:17:52.2893975Z INFO:root:Dependency Graph violations :: 0
2024-06-07T19:17:52.6505311Z INFO:root:No exisiting comment from PaC, adding a new comment...
2024-06-07T19:17:53.0645769Z INFO:root:Total unacceptable alerts :: 1
2024-06-07T19:17:53.0647791Z ERROR:root:Unacceptable Threshold of Risk has been hit!
2024-06-07T19:17:53.0649619Z  _____  _   _   ___   _____ _____                       _ _                      
2024-06-07T19:17:53.0651180Z |  __ \| | | | / _ \ /  ___/  __ \                     | (_)                     
2024-06-07T19:17:53.0653444Z | |  \/| |_| |/ /_\ \\ `--.| /  \/ ___  _ __ ___  _ __ | |_  __ _ _ __   ___ ___ 
2024-06-07T19:17:53.0655181Z | | __ |  _  ||  _  | `--. \ |    / _ \| '_ ` _ \| '_ \| | |/ _` | '_ \ / __/ _ \
2024-06-07T19:17:53.0656532Z | |_\ \| | | || | | |/\__/ / \__/\ (_) | | | | | | |_) | | | (_| | | | | (_|  __/
2024-06-07T19:17:53.0657786Z  \____/\_| |_/\_| |_/\____/ \____/\___/|_| |_| |_| .__/|_|_|\__,_|_| |_|\___\___|
2024-06-07T19:17:53.0659027Z                                                  | |                             
2024-06-07T19:17:53.0660175Z                                                  |_|         v2.7.3
2024-06-07T19:17:53.0661287Z     GitHub Advanced Security Policy as Code by GeekMasher
2024-06-07T19:17:53.0662007Z 
2024-06-07T19:17:53.0662732Z GitHub Repository :: ********/vera-busted-01
2024-06-07T19:17:53.0664290Z GitHub Instance :: https://github.com
2024-06-07T19:17:53.0665394Z GitHub Reference (branch/pr) :: refs/pull/100/merge
2024-06-07T19:17:53.0669074Z ##[group]Policy as Code
2024-06-07T19:17:53.0670993Z Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-07T19:17:53.0673053Z Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-07T19:17:53.0674591Z Loading policy file - /tmp/repo/policies/default.yml
2024-06-07T19:17:53.0675715Z Enabling Time to Remediate (global) :: codescanning
2024-06-07T19:17:53.0676853Z Policy loaded successfully
2024-06-07T19:17:53.0677780Z Saving Policy...
2024-06-07T19:17:53.0678518Z Policy saved
2024-06-07T19:17:53.0679441Z Finished loading policy
2024-06-07T19:17:53.0680363Z Policy as Code Summary:
2024-06-07T19:17:53.0681118Z ```
2024-06-07T19:17:53.0681959Z general: 'error'
2024-06-07T19:17:53.0682781Z codescanning: 'error'
2024-06-07T19:17:53.0683716Z dependabot: 'None'
2024-06-07T19:17:53.0684646Z secretscanning: 'all'
2024-06-07T19:17:53.0685492Z licensing: 'error'
2024-06-07T19:17:53.0686406Z dependencies: 'error'
2024-06-07T19:17:53.0687293Z ```
2024-06-07T19:17:53.0688766Z ##[endgroup]
2024-06-07T19:17:53.0690096Z ##[group]Code Scanning Results
2024-06-07T19:17:53.0691303Z Code Scanning Alerts from Pull Request (alert diff)
2024-06-07T19:17:53.0692494Z Total Code Scanning Alerts :: 0
2024-06-07T19:17:53.0693429Z Code Scanning violations :: 0
2024-06-07T19:17:53.0694933Z ##[endgroup]
2024-06-07T19:17:53.0696343Z ##[group]Dependabot Results
2024-06-07T19:17:53.0697394Z Dependabot Alerts from Pull Request
2024-06-07T19:17:53.0698369Z Total Dependabot Alerts :: 0
2024-06-07T19:17:53.0699390Z Dependabot violations :: 0
2024-06-07T19:17:53.0700878Z ##[endgroup]
2024-06-07T19:17:53.0702252Z ##[group]Dependency Graph
2024-06-07T19:17:53.0703766Z Dependencies from Pull Request
2024-06-07T19:17:53.0704699Z Total Dependency Graph :: 1
2024-06-07T19:17:53.0705748Z Dependency Graph violations :: 0
2024-06-07T19:17:53.0707364Z ##[endgroup]
2024-06-07T19:17:53.0708872Z ##[group]Dependency Graph Results - Licensing
2024-06-07T19:17:53.0709819Z Dependencies from Pull Request
2024-06-07T19:17:53.0711098Z Loaded extra licensing information :: 9459
2024-06-07T19:17:53.0712308Z Total Dependencies in Graph :: 1
2024-06-07T19:17:53.0713274Z Dependency Graph violations :: 0
2024-06-07T19:17:53.0714788Z ##[endgroup]
2024-06-07T19:17:53.0716154Z ##[group]Secret Scanning Results
2024-06-07T19:17:53.0717773Z ##[endgroup]
2024-06-07T19:17:53.0719208Z ##[group]Summary
2024-06-07T19:17:53.0720804Z ##[group]Pull Request comment
2024-06-07T19:17:53.0722015Z No exisiting comment from PaC, adding a new comment...
2024-06-07T19:17:53.0723708Z ##[endgroup]
2024-06-07T19:17:53.0724658Z Total unacceptable alerts :: 1
2024-06-07T19:17:53.0757327Z ##[error]Unacceptable Threshold of Risk has been hit!
2024-06-07T19:17:53.0847880Z ##[error]Process completed with exit code 1.
2024-06-07T19:17:53.0955322Z Post job cleanup.
2024-06-07T19:17:53.1836295Z There is no valid token stored in the action state, nothing to revoke.
2024-06-07T19:17:53.2039461Z Cleaning up orphan processes

Push to Main:

2024-06-07T19:14:41.1670384Z Current runner version: '2.317.0'
2024-06-07T19:14:41.1695789Z ##[group]Operating System
2024-06-07T19:14:41.1697329Z Ubuntu
2024-06-07T19:14:41.1697905Z 22.04.4
2024-06-07T19:14:41.1698519Z LTS
2024-06-07T19:14:41.1699087Z ##[endgroup]
2024-06-07T19:14:41.1699723Z ##[group]Runner Image
2024-06-07T19:14:41.1700425Z Image: ubuntu-22.04
2024-06-07T19:14:41.1701030Z Version: 20240603.1.0
2024-06-07T19:14:41.1702340Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20240603.1/images/ubuntu/Ubuntu2204-Readme.md
2024-06-07T19:14:41.1704134Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20240603.1
2024-06-07T19:14:41.1705271Z ##[endgroup]
2024-06-07T19:14:41.1705942Z ##[group]Runner Image Provisioner
2024-06-07T19:14:41.1706636Z 2.0.370.1
2024-06-07T19:14:41.1707239Z ##[endgroup]
2024-06-07T19:14:41.1710012Z ##[group]GITHUB_TOKEN Permissions
2024-06-07T19:14:41.1712019Z Actions: write
2024-06-07T19:14:41.1712806Z Attestations: write
2024-06-07T19:14:41.1713609Z Checks: write
2024-06-07T19:14:41.1714234Z Contents: write
2024-06-07T19:14:41.1714885Z Deployments: write
2024-06-07T19:14:41.1715480Z Discussions: write
2024-06-07T19:14:41.1716134Z Issues: write
2024-06-07T19:14:41.1716715Z Metadata: read
2024-06-07T19:14:41.1717351Z Packages: write
2024-06-07T19:14:41.1717998Z Pages: write
2024-06-07T19:14:41.1718519Z PullRequests: write
2024-06-07T19:14:41.1719218Z RepositoryProjects: write
2024-06-07T19:14:41.1719876Z SecurityEvents: write
2024-06-07T19:14:41.1720549Z Statuses: write
2024-06-07T19:14:41.1721214Z ##[endgroup]
2024-06-07T19:14:41.1723439Z Secret source: Actions
2024-06-07T19:14:41.1724337Z Prepare workflow directory
2024-06-07T19:14:41.2341945Z Prepare all required actions
2024-06-07T19:14:41.2497343Z Getting action download info
2024-06-07T19:14:41.3898704Z Download action repository 'peter-murray/workflow-application-token-action@v3' (SHA:dc0413987a085fa17d19df9e47d4677cf81ffef3)
2024-06-07T19:14:41.7180029Z Download action repository 'advanced-security/[email protected]' (SHA:70331f3a4dd481cefa98f5341250ac3dea2a8d5f)
2024-06-07T19:14:42.1740331Z Complete job name: Policy Testing
2024-06-07T19:14:42.2638384Z ##[group]Run peter-murray/workflow-application-token-action@v3
2024-06-07T19:14:42.2639444Z with:
2024-06-07T19:14:42.2640202Z   application_id: ***
2024-06-07T19:14:42.2655476Z   application_private_key: ***
2024-06-07T19:14:42.2656234Z   revoke_token: false
2024-06-07T19:14:42.2657283Z ##[endgroup]
2024-06-07T19:14:42.6243769Z Found GitHub Application: GHAS-Policy-as-Code
2024-06-07T19:14:42.6246268Z Obtaining application installation for repository: ********/vera-busted-01
2024-06-07T19:14:42.7553984Z {"token":"***","expires_at":"2024-06-07T20:14:42Z","permissions":{"actions":"read","contents":"read","metadata":"read","pull_requests":"write","repository_advisories":"read","repository_custom_properties":"read","secret_scanning_alerts":"read","security_events":"read","vulnerability_alerts":"read"},"repository_selection":"selected"}
2024-06-07T19:14:42.7558603Z Successfully generated an access token for application.
2024-06-07T19:14:42.7851607Z ##[group]Run advanced-security/[email protected]
2024-06-07T19:14:42.7852582Z with:
2024-06-07T19:14:42.7853586Z   token: ***
2024-06-07T19:14:42.7854744Z   policy: ********/ghas-policy-as-code
2024-06-07T19:14:42.7855833Z   policy-path: policies/default.yml
2024-06-07T19:14:42.7856998Z   policy-branch: main
2024-06-07T19:14:42.7858541Z   policy-repo-token: ***
2024-06-07T19:14:42.7859473Z   argvs: --display --pr-comment --is-github-app-token
2024-06-07T19:14:42.7860470Z   severity: error
2024-06-07T19:14:42.7861261Z   repository: ********/vera-busted-01
2024-06-07T19:14:42.7862250Z   ref: refs/heads/main
2024-06-07T19:14:42.7862974Z   action: break
2024-06-07T19:14:42.7863602Z ##[endgroup]
2024-06-07T19:14:42.8130917Z ##[group]Run echo "Running Policy as Code..."
2024-06-07T19:14:42.8132066Z �[36;1mecho "Running Policy as Code..."�[0m
2024-06-07T19:14:42.8134623Z �[36;1mexport PYTHONPATH=/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3:/home/runner/work/_actions/advanced-security/policy-as-code/v2.7.3/vendor�[0m
2024-06-07T19:14:42.8136916Z �[36;1mpython3 -m ghascompliance \�[0m
2024-06-07T19:14:42.8137913Z �[36;1m  --severity "error" \�[0m
2024-06-07T19:14:42.8138751Z �[36;1m  --action "break" \�[0m
2024-06-07T19:14:42.8139893Z �[36;1m  --github-token "***" \�[0m
2024-06-07T19:14:42.8141659Z �[36;1m  --policy-repo-token "***" \�[0m
2024-06-07T19:14:42.8142801Z �[36;1m  --github-repository "********/vera-busted-01" \�[0m
2024-06-07T19:14:42.8144078Z �[36;1m  --github-ref "refs/heads/main" \�[0m
2024-06-07T19:14:42.8145311Z �[36;1m  --github-policy "********/ghas-policy-as-code" \�[0m
2024-06-07T19:14:42.8146564Z �[36;1m  --github-policy-path "policies/default.yml" \�[0m
2024-06-07T19:14:42.8147668Z �[36;1m  --github-policy-branch "main" \�[0m
2024-06-07T19:14:42.8148767Z �[36;1m  --display --pr-comment --is-github-app-token�[0m
2024-06-07T19:14:42.8231249Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2024-06-07T19:14:42.8232361Z ##[endgroup]
2024-06-07T19:14:42.8390457Z Running Policy as Code...
2024-06-07T19:14:43.1341572Z INFO:root:GitHub Repository :: ********/vera-busted-01
2024-06-07T19:14:43.1344139Z INFO:root:GitHub Instance :: https://github.com
2024-06-07T19:14:43.1345537Z INFO:root:GitHub Reference (branch/pr) :: refs/heads/main
2024-06-07T19:14:43.1347284Z INFO:root:Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-07T19:14:43.1348725Z INFO:root:Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-07T19:14:43.6258061Z INFO:root:Loading policy file - /tmp/repo/policies/default.yml
2024-06-07T19:14:43.6399641Z INFO:root:Enabling Time to Remediate (global) :: codescanning
2024-06-07T19:14:43.6401089Z INFO:root:Policy loaded successfully
2024-06-07T19:14:43.6402144Z INFO:root:Saving Policy...
2024-06-07T19:14:43.6403144Z INFO:root:Policy saved
2024-06-07T19:14:43.6404090Z INFO:root:Finished loading policy
2024-06-07T19:14:43.6405205Z INFO:root:Policy as Code Summary:
2024-06-07T19:14:43.6406277Z INFO:root:```
2024-06-07T19:14:43.6407251Z INFO:root:general: 'error'
2024-06-07T19:14:43.6408364Z INFO:root:codescanning: 'error'
2024-06-07T19:14:43.6409464Z INFO:root:dependabot: 'None'
2024-06-07T19:14:43.6410491Z INFO:root:secretscanning: 'all'
2024-06-07T19:14:43.6411640Z INFO:root:licensing: 'error'
2024-06-07T19:14:43.6412591Z INFO:root:dependencies: 'error'
2024-06-07T19:14:43.6413647Z INFO:root:```
2024-06-07T19:14:43.8118361Z INFO:root:Total Code Scanning Alerts :: 1
2024-06-07T19:14:43.8142207Z ERROR:root:CodeQL - 2023-10-30 20:34:07 - Inefficient regular expression
2024-06-07T19:14:43.8143887Z  _____  _   _   ___   _____ _____                       _ _                      
2024-06-07T19:14:43.8145272Z |  __ \| | | | / _ \ /  ___/  __ \                     | (_)                     
2024-06-07T19:14:43.8147428Z | |  \/| |_| |/ /_\ \\ `--.| /  \/ ___  _ __ ___  _ __ | |_  __ _ _ __   ___ ___ 
2024-06-07T19:14:43.8149015Z | | __ |  _  ||  _  | `--. \ |    / _ \| '_ ` _ \| '_ \| | |/ _` | '_ \ / __/ _ \
2024-06-07T19:14:43.8150518Z | |_\ \| | | || | | |/\__/ / \__/\ (_) | | | | | | |_) | | | (_| | | | | (_|  __/
2024-06-07T19:14:43.8151957Z  \____/\_| |_/\_| |_/\____/ \____/\___/|_| |_| |_| .__/|_|_|\__,_|_| |_|\___\___|
2024-06-07T19:14:43.8153214Z                                                  | |                             
2024-06-07T19:14:43.8154467Z                                                  |_|         v2.7.3
2024-06-07T19:14:43.8155766Z     GitHub Advanced Security Policy as Code by GeekMasher
2024-06-07T19:14:43.8156504Z 
2024-06-07T19:14:43.8157209Z GitHub Repository :: ********/vera-busted-01
2024-06-07T19:14:43.8158721Z GitHub Instance :: https://github.com
2024-06-07T19:14:43.8160098Z GitHub Reference (branch/pr) :: refs/heads/main
2024-06-07T19:14:43.8164001Z ##[group]Policy as Code
2024-06-07T19:14:43.8166209Z Loading Policy as Code from Repository - https://github.com/********/ghas-policy-as-code/policies/default.yml
2024-06-07T19:14:43.8168755Z Cloning policy repo - ********/ghas-policy-as-code@main
2024-06-07T19:14:43.8170457Z Loading policy file - /tmp/repo/policies/default.yml
2024-06-07T19:14:43.8177133Z Enabling Time to Remediate (global) :: codescanning
2024-06-07T19:14:43.8178815Z Policy loaded successfully
2024-06-07T19:14:43.8179888Z Saving Policy...
2024-06-07T19:14:43.8180860Z Policy saved
2024-06-07T19:14:43.8181867Z Finished loading policy
2024-06-07T19:14:43.8183183Z Policy as Code Summary:
2024-06-07T19:14:43.8184051Z ```
2024-06-07T19:14:43.8185129Z general: 'error'
2024-06-07T19:14:43.8186284Z codescanning: 'error'
2024-06-07T19:14:43.8187429Z dependabot: 'None'
2024-06-07T19:14:43.8188592Z secretscanning: 'all'
2024-06-07T19:14:43.8189546Z licensing: 'error'
2024-06-07T19:14:43.8190623Z dependencies: 'error'
2024-06-07T19:14:43.8191555Z ```
2024-06-07T19:14:43.8194174Z ##[endgroup]
2024-06-07T19:14:43.8195817Z ##[group]Code Scanning Results
2024-06-07T19:14:43.8196780Z Total Code Scanning Alerts :: 1
2024-06-07T19:14:43.8221016Z ##[error]CodeQL - 2023-10-30 20:34:07 - Inefficient regular expression
2024-06-07T19:14:43.8222133Z INFO:root:Code Scanning violations :: 1
2024-06-07T19:14:54.3289319Z INFO:root:Total Dependabot Alerts :: 26
2024-06-07T19:14:54.3357725Z INFO:root:Dependabot violations :: 0
2024-06-07T19:15:02.5778440Z INFO:root:Total Dependency Graph :: 829
2024-06-07T19:15:02.5838228Z INFO:root:Dependency Graph violations :: 0
2024-06-07T19:15:11.0285467Z INFO:root:Loaded extra licensing information :: 9459
2024-06-07T19:15:11.0287671Z INFO:root:Total Dependencies in Graph :: 829
2024-06-07T19:15:11.0300390Z INFO:root:Dependency Graph violations :: 0
2024-06-07T19:15:11.2337908Z INFO:root:Total unacceptable alerts :: 2
2024-06-07T19:15:11.2339061Z Code Scanning violations :: 1
2024-06-07T19:15:11.2340268Z ERROR:root:Unacceptable Threshold of Risk has been hit!
2024-06-07T19:15:11.2342037Z ##[endgroup]
2024-06-07T19:15:11.2343420Z ##[group]Dependabot Results
2024-06-07T19:15:11.2390111Z Total Dependabot Alerts :: 26
2024-06-07T19:15:11.2391286Z Dependabot violations :: 0
2024-06-07T19:15:11.2392859Z ##[endgroup]
2024-06-07T19:15:11.2394306Z ##[group]Dependency Graph
2024-06-07T19:15:11.2395312Z Total Dependency Graph :: 829
2024-06-07T19:15:11.2396204Z Dependency Graph violations :: 0
2024-06-07T19:15:11.2397671Z ##[endgroup]
2024-06-07T19:15:11.2399363Z ##[group]Dependency Graph Results - Licensing
2024-06-07T19:15:11.2400562Z Loaded extra licensing information :: 9459
2024-06-07T19:15:11.2401603Z Total Dependencies in Graph :: 829
2024-06-07T19:15:11.2402675Z Dependency Graph violations :: 0
2024-06-07T19:15:11.2404177Z ##[endgroup]
2024-06-07T19:15:11.2405594Z ##[group]Secret Scanning Results
2024-06-07T19:15:11.2407038Z ##[endgroup]
2024-06-07T19:15:11.2408377Z ##[group]Summary
2024-06-07T19:15:11.2409269Z Total unacceptable alerts :: 2
2024-06-07T19:15:11.2412644Z ##[error]Unacceptable Threshold of Risk has been hit!
2024-06-07T19:15:11.2541570Z ##[error]Process completed with exit code 1.
2024-06-07T19:15:11.2634411Z Post job cleanup.
2024-06-07T19:15:11.3530451Z There is no valid token stored in the action state, nothing to revoke.
2024-06-07T19:15:11.3752208Z Cleaning up orphan processes
Screenshot 2024-06-07 at 1 21 31 PM Screenshot 2024-06-07 at 1 21 25 PM Screenshot 2024-06-07 at 1 21 15 PM

@Brutalbeard
Copy link
Author

Any thoughts on how I can troubleshoot?

@Brutalbeard
Copy link
Author

@GeekMasher pinging you now so I don't forget post holiday. Very much hoping to look at this still

@GeekMasher
Copy link
Collaborator

Hey @Brutalbeard sorry for the delay, let me check over this today and get back to you shortly

@Brutalbeard
Copy link
Author

Morning! Get a chance to find anything?

@Brutalbeard
Copy link
Author

Checking in again! Hoping to hear something before weekend

@Brutalbeard
Copy link
Author

Brutalbeard commented Jul 24, 2024

Good morning! Checking in again this week. Is there anything I can do to help with troubleshooting?

@goffinf
Copy link

goffinf commented Jul 24, 2024

Hey @Brutalbeard I have been working with this composite for a while in a large FinSer company and have seen issues similar to this. I’m recently retired so I will be happy to have a look at this to see if I can reproduce. IME the main reason for this is permissions. When you access open secrets alerts in particular you need a LOT of perms (more than you showed above). I used a GitHub app and, because of the perms, restricted access to the cert and app id to a very limited scope secrets manager role & policy (in Hashicorp Vault) bound to the reusable workflow in which this action was used (via the job_workflow_ref).

I assume you have tried disabling secrets scanning (--disable-secret-scanning) and each of the other capabilities per the docs, e.g.

parser.add_argument("--disable-caching", action="store_false")
parser.add_argument("--disable-code-scanning", action="store_true")
parser.add_argument("--disable-dependabot", action="store_true")
parser.add_argument("--disable-dependency-licensing", action="store_true")
parser.add_argument("--disable-dependencies", action="store_true")
parser.add_argument("--disable-secret-scanning", action="store_true")
parser.add_argument("--is-github-app-token", action="store_true", default=False)
parser.add_argument("--is-policy-github-app-token", action="store_true", default=False)
parser.add_argument("--pr-comment", action="store_true", default=False)

@Brutalbeard
Copy link
Author

Morning @goffinf, if you have them open still, could you toss me a link to the docs you're referencing? Happy to try whatever

@goffinf
Copy link

goffinf commented Jul 24, 2024

Hey John, it’s evening here in the UK (6p.m). The code snippet above was from the implementation. I note Mathew has recently improved the docs but when I started using this (about a year ago) they were somewhat incomplete so looking at the source was informative. The link in this case is :

https://github.com/advanced-security/policy-as-code/blob/main/ghascompliance/__main__.py

HtHs

Fraser

@Brutalbeard
Copy link
Author

I'm Denver US, so I'll have the day to go through and check out what you've noted here. Will have some comments on here to see tomorrow

@felickz
Copy link
Contributor

felickz commented Jul 25, 2024

Hey all! Appreciate your collaboration and patience here. Discussing with @GeekMasher - he was able to reproduce the issue on a test repo and has uncovered a couple of bugs that need resolved. Let's look toward next week to get something patched here. While we do maintain this project as OSS, this issue has hit during a perfect storm of travel, sickness, and OOO for the summertime for our team - apologies for the delays in comms.

@GeekMasher
Copy link
Collaborator

Hey @Brutalbeard, sorry for the delay. Turns out there was a few different issues here but they should all be fixed in v2.8.0. Please can you confirm if this issue is fixed

@Brutalbeard
Copy link
Author

Howdy! I think we're chatting about it a bit in slack, but can confirm we're getting an issue with permissions at the moment. Just dropping that note here for anyone who may be keeping an eye on this issue

@amanaknows
Copy link

amanaknows commented Aug 5, 2024

//This helps w clunky mess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants