- 
                Notifications
    
You must be signed in to change notification settings  - Fork 51
 
convert posix path back to windows #464
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
Conversation
Signed-off-by: Joseph Shapiro <[email protected]>
| 
           I see the function in question is called here, how does this work when scanning a non-Windows image on Windows?  | 
    
| 
           ooh, good though. I put a breakpoint on NewMetadataFromPath and ran a scan on "alpine:3.19" ( Maybe I am missing something though. Is there a way to scan a container like a normal file system. However, this is duplicating what syft does, so if there is a problem where you can scan a linux image fs, even thought the scanner is on windows, that might be a problem for syft as well  | 
    
| 
           I assume this function isn't being used in the image cases, we'll just need to do some due diligence to make sure. A couple things stereoscope does is scans OCI directories and saved images. If you do a  If there aren't any stereoscope functions actually calling this, we should probably move the function to Syft with the Windows fix.  | 
    
| 
           I did a search in skopeo for  so maybe it should be moved out, and fixed. maybe I am missing something though. I dont think this code can get called from cross OS, or OS to container.  | 
    
| 
           If you give the go ahead, I can change this PR to just remove the functions and testing, then make a PR on syft to handle it internally. Not sure how to do that properly, since they are different packages on different versions  | 
    
| 
           There is almost assuredly a reason it's here. The only other thing I can think of is singularity images. Let me ask the team and get back to you, I think this at least illustrates the issue. Thanks very much for working on it!  | 
    
| 
           Sorry for the delay @JoeyShapiro; after talking with folks on the team, I think the best thing is to close this PR and copy this function to Syft, with the required changes to support Windows properly, along with test to cover the functionality (existing tests here, and new tests that will run on windows). (I'm going to start migrating our build tooling so we can support Windows as a first-class citizen in our CI environment. I've already made a lot of progress on this, my own unique way, but Syft has a lot of scripting to deal with, it would be great to have a head start to prevent regressions.)  | 
    
| 
           alright sounds good. I'll close this issue, and make a PR to put it all in syft. I guess I will leave it to you and your team to delete the functions in stereoscope when you see fit.  | 
    
In syft when it creates Metadata for walked files, it will first convert it to a posix file path on windows.
https://github.com/anchore/syft/blob/18e789c4fdd96be5002dc10d7db05481ba61209c/syft/internal/fileresolver/file_indexer.go#L140
This is an issue because the metadata will open the file to determine the mime type. But the file is not a valid windows path. This will cause missing data on the SBOM creation.
I copied the
FromPosixcommand from syft, and used it to convert back, if the scanning OS is windows.I am not sure if this is the proper fix, or the best place to put it. Maybe this should be handled in syft. but I am putting this PR here first, and seeing what others think. Maybe even just simply add a
IsWindowsflag as a parameter.