forked from corsa-center/dependent-audit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
182 lines (174 loc) · 6.1 KB
/
Copy pathaction.yml
File metadata and controls
182 lines (174 loc) · 6.1 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: 'Dependency Audit Crawler'
description: 'Crawls Sourcegraph to find dependents and generates a UDG Graph + SPDX Snippets'
author: 'SupplyChainBot'
inputs:
root_repo:
description: 'The root repository to audit'
required: true
default: ${{ github.repository }}
project_name:
description: 'The short name of the project'
required: true
sourcegraph_token:
description: 'Your Sourcegraph Access Token (optional if depth=0)'
required: false
github_token:
description: 'GitHub token to pull deep repository metrics'
required: true
default: ${{ github.token }}
email:
description: 'Email for OpenAlex and CrossRef API polite pools'
required: false
default: 'audit-bot@example.com'
max_depth:
description: 'How deep to crawl the dependency tree (0 evaluates root node only)'
required: false
default: '1'
include_forks:
description: 'Set to true to search forks'
required: false
default: 'false'
include_archived:
description: 'Set to true to include archived repositories as dependents'
required: false
default: 'false'
include_vendored:
description: 'Set to true to count vendored/third-party copies as dependents'
required: false
default: 'false'
search_delay:
description: 'Seconds to wait before each Sourcegraph streaming search (throttle)'
required: false
default: '0'
search_count:
description: "Max matches Sourcegraph collects per node (integer or 'all')"
required: false
default: '5000'
disable_idf:
description: 'Set to true to disable IDF specificity gating of generic tokens'
required: false
default: 'false'
idf_cap:
description: 'Frequency-probe cap; tokens at/above this are treated as generic'
required: false
default: '300'
declared_sources:
description: "Comma-separated registries to corroborate against (e.g. 'spack'); opt-in"
required: false
default: ''
output_file:
description: 'The name of the generated JSON file'
required: false
default: 'dependency_graph.json'
upload_artifact:
description: 'If true, uploads the results as build artifacts'
required: false
default: 'false'
artifact_name:
description: 'The base name of the artifact to upload'
required: false
default: 'dependency-graph'
separate_artifacts:
description: 'If true, uploads the JSON and SPDX snippets as two separate ZIPs'
required: false
default: 'false'
custom_search_string:
description: 'A custom regex or string to search for'
required: false
custom_filename:
description: 'Limit search to this filename'
required: false
academic_keywords:
description: 'Comma separated list of unique keywords to search in full-text publications (e.g. "dyninst")'
required: false
use_defaults:
description: 'If false, disables standard C++ header/pragma searching'
required: false
default: 'true'
verbose:
description: 'Enable verbose JSON logging'
required: false
default: 'false'
runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Dependencies
shell: bash
run: pip install requests argparse
- name: Run Audit Script
shell: bash
run: |
CMD="python ${{ github.action_path }}/audit_dependents.py \
--repo '${{ inputs.root_repo }}' \
--name '${{ inputs.project_name }}' \
--depth ${{ inputs.max_depth }} \
--out '${{ inputs.output_file }}' \
--gh-token '${{ inputs.github_token }}' \
--email '${{ inputs.email }}'"
if [ -n "${{ inputs.sourcegraph_token }}" ]; then
CMD="$CMD --sg-token '${{ inputs.sourcegraph_token }}'"
fi
if [ "${{ inputs.include_forks }}" == "true" ]; then
CMD="$CMD --forks"
fi
if [ "${{ inputs.include_archived }}" == "true" ]; then
CMD="$CMD --include-archived"
fi
if [ "${{ inputs.include_vendored }}" == "true" ]; then
CMD="$CMD --include-vendored"
fi
if [ -n "${{ inputs.search_delay }}" ]; then
CMD="$CMD --sg-delay '${{ inputs.search_delay }}'"
fi
if [ -n "${{ inputs.search_count }}" ]; then
CMD="$CMD --sg-count '${{ inputs.search_count }}'"
fi
if [ "${{ inputs.disable_idf }}" == "true" ]; then
CMD="$CMD --no-idf"
fi
if [ -n "${{ inputs.idf_cap }}" ]; then
CMD="$CMD --idf-cap '${{ inputs.idf_cap }}'"
fi
if [ -n "${{ inputs.declared_sources }}" ]; then
CMD="$CMD --declared-sources '${{ inputs.declared_sources }}'"
fi
if [ -n "${{ inputs.custom_search_string }}" ]; then
CMD="$CMD --custom-string '${{ inputs.custom_search_string }}'"
fi
if [ -n "${{ inputs.custom_filename }}" ]; then
CMD="$CMD --custom-file '${{ inputs.custom_filename }}'"
fi
if [ -n "${{ inputs.academic_keywords }}" ]; then
CMD="$CMD --academic-keyword '${{ inputs.academic_keywords }}'"
fi
if [ "${{ inputs.use_defaults }}" == "false" ]; then
CMD="$CMD --no-defaults"
fi
if [ "${{ inputs.verbose }}" == "true" ]; then
CMD="$CMD --verbose"
fi
eval $CMD
- name: Upload Combined Artifact
if: inputs.upload_artifact == 'true' && inputs.separate_artifacts == 'false'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: |
${{ inputs.output_file }}
spdx_snippets/
- name: Upload JSON Graph (Separated)
if: inputs.upload_artifact == 'true' && inputs.separate_artifacts == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}-json
path: ${{ inputs.output_file }}
- name: Upload SPDX Snippets (Separated)
if: inputs.upload_artifact == 'true' && inputs.separate_artifacts == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}-spdx
path: spdx_snippets/