Repository navigation
XRAY-170058 - Supports requirements file flag in jf ca #952
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -94,6 +94,8 @@ const ( | |||||
|
|
||||||
| errorTemplateUnsupportedTech = "It looks like this project uses '%s' to download its dependencies. " + | ||||||
| "This package manager however isn't supported by this command." | ||||||
| errorNothingAudited = "no supported package manager was recognised in any working directory, so nothing was audited. " + | ||||||
| "Check the working directories, or pass --requirements-file for a custom pip file name." | ||||||
|
|
||||||
| WaiverRequestForbidden = "One or more policies blocking this package do not allow waiver requests." | ||||||
| WaiverRequestApproved = "The waiver request was automatically granted; you can use this package.\nNOTE: The policy owner may review this waiver more thoroughly and contact you if issues are found." | ||||||
|
|
@@ -311,7 +313,9 @@ type CurationAuditCommand struct { | |||||
| dockerImageName string | ||||||
| huggingFaceModel string | ||||||
| // hfProjectNameHint is the collision-free HF root-node name for the current working dir. | ||||||
| hfProjectNameHint string | ||||||
| hfProjectNameHint string | ||||||
| // detectedTechCount counts technologies detected across all working dirs; zero fails the run. | ||||||
| detectedTechCount int | ||||||
| includeCachedPackages bool | ||||||
| mvnIncludePluginDeps bool | ||||||
| scriptPath string | ||||||
|
|
@@ -495,6 +499,9 @@ func (ca *CurationAuditCommand) Run() (err error) { | |||||
| if ca.Progress() != nil { | ||||||
| err = errors.Join(err, ca.Progress().Quit()) | ||||||
| } | ||||||
| if err == nil && ca.detectedTechCount == 0 { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Runs that produce no audit report (an unsupported-only directory such as
Suggested change
One question: an HF run where every reference is unresolved or dynamic still adds a warnings-only placeholder to Review generated by xray-pr-review |
||||||
| err = errorutils.CheckErrorf(errorNothingAudited) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the exit-code change (exit 0 → error when nothing is audited) part of XRAY-170058's scope? It also applies to the curation-after-failure path (an extra Review generated by xray-pr-review |
||||||
| } | ||||||
| // Print after the spinner has stopped so messages are not overwritten by ANSI clear codes. | ||||||
| for _, w := range ca.pendingWarnings { | ||||||
| log.Warn(w) | ||||||
|
|
@@ -780,7 +787,7 @@ func (ca *CurationAuditCommand) techsToAudit() []string { | |||||
| log.Debug(fmt.Sprintf("Docker image name '%s' was provided, running Docker curation audit.", ca.DockerImageName())) | ||||||
| return []string{techutils.Docker.String()} | ||||||
| default: | ||||||
| techs := promotePnpmWorkspaceMember(techutils.DetectedTechnologiesListForCurationAudit()) | ||||||
| techs := promotePnpmWorkspaceMember(techutils.DetectedTechnologiesListForCurationAuditWithRequirementsFile(ca.PipRequirementsFile())) | ||||||
| techs = promoteYarnWorkspaceMember(techs) | ||||||
| techs = promotePipToUvIn(techs, ca.OriginPath) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With a machine-global func (ca *CurationAuditCommand) promotePipToUv(techs []string) []string {
if ca.PipRequirementsFile() == "" || ca.OriginPath == "" {
return promotePipToUvIn(techs, ca.OriginPath)
}
if _, statErr := os.Stat(filepath.Join(ca.OriginPath, ca.PipRequirementsFile())); statErr != nil {
return promotePipToUvIn(techs, ca.OriginPath)
}
promoted := techutils.PromotePipToUv(techutils.ToTechnologies(techs), ca.OriginPath)
result := make([]string, 0, len(promoted))
for _, t := range promoted {
result = append(result, t.String())
}
return result
}A Review generated by xray-pr-review |
||||||
| techs = dedupeDotnetFromNuget(techs) | ||||||
|
|
@@ -830,6 +837,7 @@ func (ca *CurationAuditCommand) doCurateAudit(results map[string]*CurationReport | |||||
| return err | ||||||
| } | ||||||
| techs := ca.techsToAudit() | ||||||
| ca.detectedTechCount += len(techs) | ||||||
| for _, tech := range techs { | ||||||
| supportedFunc, ok := supportedTech[techutils.Technology(tech)] | ||||||
| if !ok { | ||||||
|
|
||||||
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.
When
--requirements-filewas passed but matched nothing, the "pass --requirements-file" hint isn't actionable. Consider naming the value only when it is set (the wording is neutral because the same error also covers unsupported-only and HF-empty runs):plus a small helper that picks the message, used at the call site in
Run():Review generated by xray-pr-review