Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions commands/curation/curationaudit.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ func (ca *CurationAuditCommand) auditTree(tech techutils.Technology, results map
if err != nil {
return err
}
if tech == techutils.Pip || tech == techutils.Poetry || tech == techutils.Pipenv {
if tech == techutils.Pip || tech == techutils.Poetry || tech == techutils.Pipenv || tech == techutils.Uv {
rtManager, err = boundedRedirectManager(serverDetails)
if err != nil {
return err
Expand Down Expand Up @@ -2208,7 +2208,7 @@ func (nc *treeAnalyzer) fetchNodeStatus(node xrayUtils.GraphNode, p *sync.Map) e
requestDetails := nc.httpClientDetails.Clone()
var resp *http.Response
var err error
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv {
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv || nc.tech == techutils.Uv {
resp, _, err = nc.sendBoundedRequest(http.MethodHead, packageUrl, requestDetails)
} else {
resp, _, err = nc.rtManager.Client().SendHead(packageUrl, requestDetails)
Expand Down Expand Up @@ -2289,7 +2289,7 @@ func (ca *CurationAuditCommand) runCvsFallback(cvsErr *python.CvsBlockedError, t
if err != nil {
return fmt.Errorf("curation-blocked resolution fallback: failed to get Artifactory manager (%w); %s error: %w", err, tech, cvsErr)
}
if tech == techutils.Pip || tech == techutils.Poetry || tech == techutils.Pipenv {
if tech == techutils.Pip || tech == techutils.Poetry || tech == techutils.Pipenv || tech == techutils.Uv {
rtManager, err = boundedRedirectManager(serverDetails)
if err != nil {
return fmt.Errorf("curation-blocked resolution fallback: failed to create bounded HTTP manager: %w", err)
Expand Down Expand Up @@ -2570,7 +2570,7 @@ func (nc *treeAnalyzer) lookupPypiAllVersions(name string) ([]string, error) {
var resp *http.Response
var body []byte
var err error
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv {
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv || nc.tech == techutils.Uv {
resp, body, err = nc.sendBoundedRequest(http.MethodGet, metadataURL, requestDetails)
} else {
resp, body, _, err = nc.rtManager.Client().SendGet(metadataURL, true, requestDetails)
Expand Down Expand Up @@ -2610,7 +2610,7 @@ func (nc *treeAnalyzer) lookupPypiNormalDownloadURL(name, ver string) (string, e
var resp *http.Response
var body []byte
var err error
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv {
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv || nc.tech == techutils.Uv {
resp, body, err = nc.sendBoundedRequest(http.MethodGet, metadataURL, requestDetails)
} else {
resp, body, _, err = nc.rtManager.Client().SendGet(metadataURL, true, requestDetails)
Expand Down Expand Up @@ -2711,7 +2711,7 @@ func (nc *treeAnalyzer) fetchCvsBlockedStatus(pins []python.PinnedRequirement) [
headDetails := nc.httpClientDetails.Clone()
var headResp *http.Response
var headErr error
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv {
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv || nc.tech == techutils.Uv {
headResp, _, headErr = nc.sendBoundedRequest(http.MethodHead, dlURL, headDetails)
} else {
headResp, _, headErr = nc.rtManager.Client().SendHead(dlURL, headDetails)
Expand Down Expand Up @@ -2811,7 +2811,7 @@ func (nc *treeAnalyzer) getBlockedPackageDetails(packageUrl string, name string,
var getResp *http.Response
var respBody []byte
var err error
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv {
if nc.tech == techutils.Pip || nc.tech == techutils.Poetry || nc.tech == techutils.Pipenv || nc.tech == techutils.Uv {
getResp, respBody, err = nc.sendBoundedRequest(http.MethodGet, packageUrl, requestDetails)
} else {
getResp, respBody, _, err = nc.rtManager.Client().SendGet(packageUrl, true, requestDetails)
Expand Down
16 changes: 11 additions & 5 deletions commands/curation/curationaudit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4497,7 +4497,7 @@ url = "https://pypi.org/simple"
}

func TestSendBoundedRequestRejectsRedirectOutsideRepository(t *testing.T) {
for _, tech := range []techutils.Technology{techutils.Pip, techutils.Poetry, techutils.Pipenv} {
for _, tech := range []techutils.Technology{techutils.Pip, techutils.Poetry, techutils.Pipenv, techutils.Uv} {
t.Run(tech.String(), func(t *testing.T) {
var outsideRequested atomic.Bool
var requests atomic.Int32
Expand Down Expand Up @@ -4554,7 +4554,7 @@ func TestCvsMetadataRejectsRedirectOutsideRepository(t *testing.T) {
},
},
}
for _, tech := range []techutils.Technology{techutils.Pip, techutils.Poetry, techutils.Pipenv} {
for _, tech := range []techutils.Technology{techutils.Pip, techutils.Poetry, techutils.Pipenv, techutils.Uv} {
for _, test := range tests {
t.Run(tech.String()+"/"+test.name, func(t *testing.T) {
var outsideRequested atomic.Bool
Expand Down Expand Up @@ -4594,7 +4594,7 @@ func TestCvsMetadataRejectsRedirectOutsideRepository(t *testing.T) {
// tech-branch in fetchNodeStatus (not sendBoundedRequest directly) to guard against a
// regression that silently narrows the bounded-redirect condition back to Pipenv only.
func TestFetchNodeStatusRoutesPipAndPoetryThroughBoundedRedirects(t *testing.T) {
for _, tech := range []techutils.Technology{techutils.Pip, techutils.Poetry, techutils.Pipenv} {
for _, tech := range []techutils.Technology{techutils.Pip, techutils.Poetry, techutils.Pipenv, techutils.Uv} {
t.Run(tech.String(), func(t *testing.T) {
var outsideRequested atomic.Bool
var requests atomic.Int32
Expand Down Expand Up @@ -5046,7 +5046,7 @@ func TestFetchCvsBlockedStatusUv(t *testing.T) {
blockResponse := fmt.Sprintf(`{"errors":[{"status":403,"message":%q}]}`, blockMsg)
versionMetaJSON := fmt.Sprintf(`{"urls":[{"packagetype":"bdist_wheel","url":"../../%s"}]}`, whlRelativePath)

serverMock, _, rtManager := coreCommonTests.CreateRtRestsMockServer(t, func(w http.ResponseWriter, r *http.Request) {
serverMock, serverDetails, _ := coreCommonTests.CreateRtRestsMockServer(t, func(w http.ResponseWriter, r *http.Request) {
switch {
case r.Method == http.MethodGet && strings.Contains(r.URL.Path, "/pypi/"+blockedPkg+"/"+blockedVer+"/json"):
w.WriteHeader(http.StatusOK)
Expand All @@ -5062,6 +5062,9 @@ func TestFetchCvsBlockedStatusUv(t *testing.T) {
})
defer serverMock.Close()

// Zero retries required; see SendWithBoundedRedirects.
rtManager, err := rtUtils.CreateServiceManager(serverDetails, 0, 0, false)
require.NoError(t, err)
rtAuth := rtManager.GetConfig().GetServiceDetails()
httpClientDetails := rtAuth.CreateHttpClientDetails()

Expand Down Expand Up @@ -5120,7 +5123,7 @@ func TestFetchCvsBlockedStatusUvTransitive(t *testing.T) {
allVersionsJSON := `{"releases":{"1.4.0":[],"1.4.1":[],"1.4.5":[],"1.4.7":[]}}`
versionMetaJSON := fmt.Sprintf(`{"urls":[{"packagetype":"bdist_wheel","url":"../../%s"}]}`, whlRelativePath)

serverMock, _, rtManager := coreCommonTests.CreateRtRestsMockServer(t, func(w http.ResponseWriter, r *http.Request) {
serverMock, serverDetails, _ := coreCommonTests.CreateRtRestsMockServer(t, func(w http.ResponseWriter, r *http.Request) {
switch {
case r.Method == http.MethodGet && strings.HasSuffix(r.URL.Path, "/pypi/"+blockedPkg+"/json"):
w.WriteHeader(http.StatusOK)
Expand All @@ -5139,6 +5142,9 @@ func TestFetchCvsBlockedStatusUvTransitive(t *testing.T) {
})
defer serverMock.Close()

// Zero retries required; see SendWithBoundedRedirects.
rtManager, err := rtUtils.CreateServiceManager(serverDetails, 0, 0, false)
require.NoError(t, err)
rtAuth := rtManager.GetConfig().GetServiceDetails()
httpClientDetails := rtAuth.CreateHttpClientDetails()

Expand Down
4 changes: 2 additions & 2 deletions sca/bom/buildinfo/technologies/pnpm/pnpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestBuildDependencyTreeLimitedDepth(t *testing.T) {
name: "With transitive dependencies",
treeDepth: "1",
expectedUniqueDeps: []string{
"npm://axios:1.19.0",
"npm://axios:1.18.1",
"npm://balaganjs:1.0.0",
"npm://yargs:13.3.0",
"npm://zen-website:1.0.0",
Expand All @@ -56,7 +56,7 @@ func TestBuildDependencyTreeLimitedDepth(t *testing.T) {
Nodes: []*xrayUtils.GraphNode{
{
Id: "npm://balaganjs:1.0.0",
Nodes: []*xrayUtils.GraphNode{{Id: "npm://axios:1.19.0"}, {Id: "npm://yargs:13.3.0"}},
Nodes: []*xrayUtils.GraphNode{{Id: "npm://axios:1.18.1"}, {Id: "npm://yargs:13.3.0"}},
},
},
},
Expand Down
Loading