-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Build: Add agent scan to detect automated accounts #34293
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
736e4e2
Ci: add agent scan to detect automated accounts
huang-julien ce6cbfe
fix: add missing members
huang-julien 48795ac
fix: add Ari
huang-julien 94fb10f
Merge remote-tracking branch 'origin/next' into ci/agent-scan
huang-julien 8da9f16
ci: update comment and labevl
huang-julien 013d294
fix: conditions
huang-julien 84e6785
ci: fix bot names
huang-julien f8c8258
feedbacks
huang-julien f77b608
refactor: move scripts into JS files
huang-julien a0c2ec2
chore: update comment
huang-julien a8658a3
fix: label all agent-scan
huang-julien ccccb09
ci: update add app token
huang-julien afd5505
ci(agent-scan): fix token and set target branch and envirment
huang-julien 1ff1d08
ci(agent-scan): rollback to GHTOKEN
huang-julien 487e644
feat: don't close community-flagged accounts, flag them
huang-julien c969bcd
refactor: improve script
huang-julien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import * as core from '@actions/core'; | ||
| import * as github from '@actions/github'; | ||
|
|
||
| /** | ||
| * agent scan classification rename | ||
| * - organic -> human | ||
| * - automated | ||
| * - mixed | ||
| */ | ||
| const CLASSIFICATION_MAP = { | ||
| organic: 'human', | ||
| automation: 'automated', | ||
| }; | ||
|
|
||
| async function main() { | ||
| const classification = core.getInput('classification', { required: true }); | ||
| const token = core.getInput('token', { required: true }); | ||
| const isCommunityFlagged = core.getInput('community-flagged') === 'true'; | ||
|
|
||
| const octokit = github.getOctokit(token); | ||
| const prNumber = github.context.payload.pull_request.number; | ||
|
|
||
| const labels = [`agent-scan:${CLASSIFICATION_MAP[classification] ?? classification}`]; | ||
| if (isCommunityFlagged) { | ||
| labels.push('agent-scan:community-flagged'); | ||
| } | ||
| await octokit.rest.issues.addLabels({ | ||
| ...github.context.repo, | ||
| issue_number: prNumber, | ||
| labels: labels, | ||
| }); | ||
| } | ||
|
|
||
| main().catch((error) => { | ||
| core.setFailed(error.message); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "private": true, | ||
| "type": "module", | ||
| "dependencies": { | ||
| "@actions/core": "^1.11.1", | ||
| "@actions/github": "^6.0.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: agent-scan | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| branches: | ||
| - next | ||
| - main | ||
|
|
||
| concurrency: | ||
| group: agent-scan-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| agentscan: | ||
| if: github.repository_owner == 'storybookjs' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | ||
| - name: Install script dependencies | ||
| run: npm install --prefix .github/scripts | ||
| - name: Cache AgentScan analysis | ||
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 | ||
| with: | ||
| path: .agentscan-cache | ||
| key: agentscan-cache-${{ github.actor }} | ||
| restore-keys: agentscan-cache- | ||
| - name: AgentScan | ||
| id: agentscan | ||
| uses: MatteoGabriele/agentscan-action@a584774dd15cabe6df4c6ab45fc43514a3b56b2d | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| skip-members: "dependabot[bot],AriPerkkio,huang-julien,MichaelArestad,yannbf,vanessayuenn,jonniebigodes,Sidnioulz,kasperpeulen,valentinpalkovic,github-actions[bot],ndelangen,shilman,JReinhold,ghengeveld,storybook-bot,kylegach" | ||
| agent-scan-comment: false | ||
| cache-path: .agentscan-cache | ||
| - name: Label PR with classification | ||
| env: | ||
| INPUT_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| INPUT_CLASSIFICATION: ${{ steps.agentscan.outputs.classification }} | ||
| run: node .github/scripts/agent-scan-label-pr.mjs | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Agent scan scans by accounts activity, not PR content.
It's goal is to detect highly automated accounts so it probably doesn't makes sense to scan us. Otherwise if someone's flagged, all hist future PRs will be flagged too 😂
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.
Thanks for clarifying :) Let's see if it's not too painful to add group support to agent-scan, otherwise feel free to resolve this.