-
-
Notifications
You must be signed in to change notification settings - Fork 553
77 lines (68 loc) · 2.27 KB
/
llm_checks.yml
File metadata and controls
77 lines (68 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# SECURITY:
#
# This workflow runs on pull_request_target and has write privileges.
# Those are used to add labels to the PR.
#
# **IF a user can run code in here, they would be able to extract our secrets.**
#
# This is why it doesn't run external scripts.
# The exception is the get_real_pr_shas.yml workflow.
# The input of it is santized.
name: AI/LLM Checks
on:
pull_request_target:
jobs:
real_pr_shas:
uses: rizinorg/rizin/.github/workflows/get_real_pr_shas.yml@dev
ai_checks:
name: LLM checks
permissions:
pull-requests: write
runs-on: ubuntu-latest
needs: real_pr_shas
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history needed for commit scanning
- name: Validate input hashes
env:
BASE_SHA: ${{ needs.real_pr_shas.outputs.BASE_SHA }}
HEAD_SHA: ${{ needs.real_pr_shas.outputs.HEAD_SHA }}
run: |
if echo "$BASE_SHA" | grep -q "[^a-f0-9]"; then
echo "BASE_SHA is malformed: $BASE_SHA"
exit 1
fi
if echo "$HEAD_SHA" | grep -q "[^a-f0-9]"; then
echo "HEAD_SHA is malformed: $HEAD_SHA"
exit 1
fi
- name: Check AGENT.md is unchanged
env:
BASE_SHA: ${{ needs.real_pr_shas.outputs.BASE_SHA }}
run: |
diff=$(git diff --name-status "$BASE_SHA" AGENTS.md)
if [[ $? -eq 128 ]]; then
echo "Failed to diff"
exit 1
fi
if [[ -n "$diff" ]]; then
echo "Edits to 'AGENT.md' are not allowed!"
exit 1
fi
- name: Check for AI usage and label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}
BASE_SHA: ${{ needs.real_pr_shas.outputs.BASE_SHA }}
HEAD_SHA: ${{ needs.real_pr_shas.outputs.HEAD_SHA }}
COMMIT_MSGS: ${{ needs.real_pr_shas.outputs.COMMIT_MSGS }}
run: |
LABEL_NAME="AI/LLM"
NEEDLE="Co-authored-by agent"
if echo "$COMMIT_MSGS" | grep -q "$NEEDLE"; then
echo "Authored by AI agent"
gh pr --repo $REPO edit $NUMBER --add-label "$LABEL_NAME"
fi