Skip to content

Conversation

p1gc0rn
Copy link
Collaborator

@p1gc0rn p1gc0rn commented Aug 1, 2025

The new feature helps determine the reachability of imported Python libraries in a Python project. This is part of the under developing project for imported Python libraries' reachability.

This PR includes the support for imported Python libraries defined in poetry.lock file.

@p1gc0rn p1gc0rn requested a review from cuixq August 1, 2025 01:18
@p1gc0rn p1gc0rn changed the title Add the main file for package reachability level #feat Add the main file for package reachability level Aug 1, 2025
@p1gc0rn p1gc0rn changed the title #feat Add the main file for package reachability level feat: Add the main file for package reachability level Aug 1, 2025
@cuixq
Copy link
Contributor

cuixq commented Aug 1, 2025

can you add some description for this PR?

Copy link
Contributor

@cuixq cuixq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also let's move this to experimental/pythonreach folder and add a README file.

@p1gc0rn p1gc0rn changed the title feat: Add the main file for package reachability level feat: Add the main file for determine package reachability level of Python project Aug 17, 2025
@@ -0,0 +1,415 @@
# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this example project is being referenced anywhere in test?

Dependencies []string // Direct dependencies declared in library's metadata
}

// Constants for terminal output formatting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment should be removed?


// 6. Comparison between the collected imported libraries and the PYPI dependencies of the libraries
// to find the reachability of the PYPI dependencies.
for _, library := range importedLibraries {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make a struct for the output so that we can test the reachability result properly as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/google/osv-scalibr/blob/main/enricher/reachability/java/java.go can be a reference about what the results should look like.


for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may use t.Context() for context in testing

}
}

// To compare slices, we need a canonical order.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the main entry point will be a single string so we probably don't need to sort it.

response, _ := reg.GetIndex(ctx, libraryInfo.Name)
downloadURL := ""
fileName := strings.ToLower(fmt.Sprintf(`%s-%s.tar.gz`, libraryInfo.Name, libraryInfo.Version))
for _, file := range response.Files {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


//fmt.Printf("Looking for file %s\n", fileName)
if file.Name == fileName {
downloadURL = file.URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break the loop? since the file is found

}
}

downloadFileSource, err := downloadPackageSource(downloadURL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1 @@
#!/bin/bash No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any particular reason that we want to keep this shell script?

@@ -0,0 +1,3 @@
print('hello')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add newline to end of these test files if that won't bring any trouble

@cuixq
Copy link
Contributor

cuixq commented Sep 24, 2025

we probably need go.mod as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants