@@ -14,16 +14,21 @@ action:
1414 - task :
1515 command : |
1616 set -e
17- if ! command -v gh &>/dev/null; then
18- echo "Installing GitHub CLI..."
19- (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
20- sudo mkdir -p -m 755 /etc/apt/keyrings
21- out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
22- sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
23- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
24- sudo apt update && sudo apt install gh -y
17+ if command -v gh &>/dev/null; then
18+ echo "gh already installed: $(gh --version | head -1)"
19+ exit 0
2520 fi
21+ echo "Installing GitHub CLI..."
22+ (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
23+ sudo mkdir -p -m 755 /etc/apt/keyrings
24+ out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
25+ sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
26+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
27+ sudo apt update && sudo apt install gh -y
2628 echo "gh version: $(gh --version | head -1)"
29+ - task :
30+ command : |
31+ set -e
2732 TOKEN=$(git credential fill <<EOF | grep password | cut -d= -f2
2833 protocol=https
2934 host=github.com
@@ -32,14 +37,22 @@ action:
3237 )
3338 echo "$TOKEN" | gh auth login --with-token
3439 gh auth status
40+ - task :
41+ command : |
42+ set -e
43+ OWNER=$(gh repo view --json owner -q '.owner.login')
44+ REPO=$(gh repo view --json name -q '.name')
45+ gh api "repos/${OWNER}/${REPO}/code-scanning/alerts" \
46+ --jq '[.[] | select(.state=="open")] | sort_by(.rule.security_severity_level // "low") | reverse | .[0]' \
47+ > /tmp/codescan-alert.json
48+ echo "Selected alert:"
49+ cat /tmp/codescan-alert.json | head -50
3550 - agent :
3651 prompt : |
37- Query the GitHub code scanning alerts for this repository using the GitHub CLI:
38-
39- gh api repos/{owner}/{repo}/code-scanning/alerts \
40- --jq '[.[] | select(.state=="open")] | sort_by(.rule.security_severity_level // "low") | reverse | .[0]'
52+ Read the file /tmp/codescan-alert.json which contains the highest-severity
53+ open code scanning alert for this repository.
4154
42- From the highest-severity open alert, extract:
55+ From the alert, extract:
4356 1. Alert number and HTML URL
4457 2. Rule ID and description
4558 3. Severity level
0 commit comments