Commit 81b3804
authored
✨ Skip checks that don't apply to the current repo type (#5000)
* ✨ Skip checks that don't apply to the current repo type
Scorecard's Azure DevOps support runs every check regardless of
whether it makes sense for the platform. Checks like
Dangerous-Workflow and Token-Permissions look exclusively at
GitHub Actions files and produce misleading results on non-GitHub
repos.
The repos field in checks.yaml already listed supported platforms
per check, but nothing enforced it at runtime. Now GetEnabled
reads that field and drops checks that don't list the repo's
platform.
- Add RepoType to the Repo interface (GitHub, GitLab,
Azure DevOps, local) with implementations on all four concrete
types and the mock
- Pass RepoType through to policy.GetEnabled, which filters
checks against checks.yaml's repos field
- Tag 11 checks as supporting Azure DevOps based on which
client methods are actually implemented
Signed-off-by: Jamie Magee <jamie.magee@gmail.com>
* Fix repo-type filtering: cache docs, case-insensitive lookup, pass type in serve
- Parse checks.yaml once per GetEnabled call instead of per-check
- Use case-insensitive check name lookup so CLI args like
'binary-artifacts' don't bypass the repo-type filter
- Pass repo.Type() in serve.go where the repo is already available
Signed-off-by: Jamie Magee <jamie.magee@gmail.com>
* Skip docs parsing when repoType is empty, use O(1) lookup map
- Only call docs.Read() when repoType is non-empty
- Build a lowercased name -> supported types map once per
GetEnabled call instead of O(N) GetChecks() scan per check
Signed-off-by: Jamie Magee <jamie.magee@gmail.com>
* Cache parsed checks.yaml with sync.Once in docs.Read()
The embedded YAML is immutable at runtime, so parsing it
once and reusing the result is safe. Avoids repeated
unmarshalling across GetEnabled calls in cron/multi-repo
paths.
Signed-off-by: Jamie Magee <jamie.magee@gmail.com>
* Fix lint: rename cachedErr to errCachedRead, fix var block ordering
Signed-off-by: Jamie Magee <jamie.magee@gmail.com>
---------
Signed-off-by: Jamie Magee <jamie.magee@gmail.com>1 parent 56e538e commit 81b3804
File tree
15 files changed
+162
-27
lines changed- clients
- azuredevopsrepo
- githubrepo
- gitlabrepo
- localdir
- mockclients
- cmd
- cron/internal/worker
- docs/checks
- internal
- pkg/scorecard
- policy
15 files changed
+162
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
169 | 174 | | |
170 | 175 | | |
171 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
| |||
29 | 43 | | |
30 | 44 | | |
31 | 45 | | |
| 46 | + | |
| 47 | + | |
32 | 48 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| 47 | + | |
40 | 48 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
| |||
0 commit comments