MCPcopy
hub / github.com/ossf/scorecard / processRepo

Function processRepo

cmd/root.go:281–349  ·  view source on GitHub ↗

processRepo performs the scanning and formatting for a single repo URI. It returns the Result when successful or an error describing why the URI should be skipped.

(
	ctx context.Context,
	uri string,
	o *options.Options,
	enabledProbes []string,
	enabledChecks checker.CheckNameToFnMap,
	opts []scorecard.Option,
	checkDocs docs.Doc,
	pol *policy.ScorecardPolicy,
)

Source from the content-addressed store, hash-verified

279// It returns the Result when successful or an error describing why the URI
280// should be skipped.
281func processRepo(
282 ctx context.Context,
283 uri string,
284 o *options.Options,
285 enabledProbes []string,
286 enabledChecks checker.CheckNameToFnMap,
287 opts []scorecard.Option,
288 checkDocs docs.Doc,
289 pol *policy.ScorecardPolicy,
290) (*scorecard.Result, error) {
291 var repo clients.Repo
292 var err error
293
294 if o.Local != "" && uri == o.Local {
295 repo, err = localdir.MakeLocalDirRepo(uri)
296 if err != nil {
297 return nil, fmt.Errorf("localdir: %w", err)
298 }
299 } else {
300 repo, err = makeRepo(uri)
301 if err != nil {
302 return nil, err
303 }
304 }
305
306 // Start banners with repo uri (show banners in default format only)
307 if o.Format == options.FormatDefault {
308 if len(enabledProbes) > 0 {
309 printProbeStart(uri, enabledProbes)
310 } else {
311 printCheckStart(uri, enabledChecks)
312 }
313 }
314
315 result, err := scorecard.Run(ctx, repo, opts...)
316 if err != nil {
317 return nil, fmt.Errorf("run: %w", err)
318 }
319
320 result.Metadata = append(result.Metadata, o.Metadata...)
321
322 // Stable order
323 sort.Slice(result.Checks, func(i, j int) bool {
324 return result.Checks[i].Name < result.Checks[j].Name
325 })
326
327 // End banners BEFORE RESULTS
328 if o.Format == options.FormatDefault {
329 if len(enabledProbes) > 0 {
330 printProbeResults(uri, enabledProbes)
331 } else {
332 printCheckResults(uri, enabledChecks)
333 fmt.Fprintln(os.Stderr, "\nRESULTS\n-------")
334 }
335 }
336
337 if err := scorecard.FormatResults(o, &result, checkDocs, pol); err != nil {
338 fmt.Fprintf(os.Stderr, "Failed to format results for %s: %v\n", uri, err)

Callers 1

rootCmdFunction · 0.85

Calls 8

MakeLocalDirRepoFunction · 0.92
RunFunction · 0.92
FormatResultsFunction · 0.92
makeRepoFunction · 0.85
printProbeStartFunction · 0.85
printCheckStartFunction · 0.85
printProbeResultsFunction · 0.85
printCheckResultsFunction · 0.85

Tested by

no test coverage detected