Skip to content
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

SAVE failing to locate the file specified by artifactLocation in the SARIF content #489

Closed
0x6675636b796f75676974687562 opened this issue Feb 14, 2023 · 0 comments · Fixed by #504
Assignees
Labels
bug Something isn't working

Comments

@0x6675636b796f75676974687562
Copy link
Member

TL;DR

The cause of the issue is that artifactLocation may be a path (an absolute or relative), and it can also be a file: or an https:// URI, which we don't currently support, e.g.:

A relative URI holding a relative path

"artifactLocation": {
                  "uri": "io/kb.c",
                  "index": 0
                }

A relative URI holding a relative path with a uriBaseId

"artifactLocation": {
                  "uri": "examples/Xss.js",
                  "uriBaseId": "%SRCROOT%",
                  "index": 0
                }

An absolute HTTPS URI

"artifactLocation": {
                  "uri": "https://github.com/ossf/scorecard/blob/main/actions/entrypoint.sh"
                }

An absolute file: URI holding an absolute Windows path

"artifactLocation" : {
            "uri" : "file:///D:/fake-uri.bsl"
          }

Currently, we don't support file: URIs.

The issue equally affects both save-0.3.6 and save-0.3.7.

Non-goals

Sample save.toml

[general]  
    execCmd = "pylint"
    tags = ["..."]
    description = "..."
    suiteName = "..."
    runConfigPattern = "..."

[fix]
	actualFixFormat = "SARIF"
	actualFixSarifFileName = "xyz.sarif"
	execFlags="-f sarif -d all -e ... --output xyz.sarif"

Test cases

Case 1: Windows, artifactLocation contains an absolute file: URI with an absolute path

Example:

                "artifactLocation": {
                  "uri": "file:///C:/path/to/file.py"
                }

Running save --log all . results in the following exception:

Couldn't find appropriate target file on the path file:/C:/path/to/file.py, which provided in Sarif!
Uncaught Kotlin exception: kotlin.NoSuchElementException: Collection contains no element matching the predicate.
    at 0   ???                                 7ff7a888baa2       kfun:com.saveourtool.save.plugins.fix.FixPlugin.handleFiles$lambda$3#internal + 17410 
    at 1   ???                                 7ff7a888ec86       kfun:com.saveourtool.save.plugins.fix.FixPlugin.$handleFiles$lambda$3$FUNCTION_REFERENCE$53.invoke#internal + 70 
    at 2   ???                                 7ff7a85fa441       kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 417 
    at 3   ???                                 7ff7a85fa494       kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 500 
    at 4   ???                                 7ff7a890c955       kfun:com.saveourtool.save.core.Save.executePlugin#internal + 981 
    at 5   ???                                 7ff7a890b468       kfun:com.saveourtool.save.core.Save#performAnalysis(){}com.saveourtool.save.core.reporter.Reporter + 6056 
    at 6   ???                                 7ff7a8915074       kfun:com.saveourtool.save.cli#main(kotlin.Array<kotlin.String>){} + 1732 
    at 7   ???                                 7ff7a894f8b7       Init_and_run_start + 503 
    at 8   ???                                 7ff7a894f9bf       Konan_main + 15 
    at 9   ???                                 7ff7a85613b4       __tmainCRTStartup + 564 
    at 10  ???                                 7ff7a856150b       mainCRTStartup + 27 
    at 11  ???                                 7ffc50237034       _ZSt25__throw_bad_function_callv + 19990731460 
    at 12  ???                                 7ffc509426a1       _ZSt25__throw_bad_function_callv + 19998118193 

Case 2: Windows, artifactLocation contains an absolute file: URI with a relative path

Uncaught Kotlin exception: okio.FileNotFoundException: no such file
    at 0   ???                                 7ff7a865b168       kfun:okio#variantCanonicalize__at__okio.PosixFileSystem(okio.Path){}okio.Path + 1704 
    at 1   ???                                 7ff7a887df9c       kfun:com.saveourtool.sarifutils.adapter.SarifFixAdapter.applyReplacementsToFiles#internal + 1260 
    at 2   ???                                 7ff7a88801ec       kfun:com.saveourtool.sarifutils.adapter.SarifFixAdapter.process$lambda$0#internal + 3884 
    at 3   ???                                 7ff7a85fb0f4       kfun:kotlin.sequences.$flatMapIndexed$lambda$5COROUTINE$16.invokeSuspend#internal + 612 
    at 4   ???                                 7ff7a856c0c1       kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 241 
    at 5   ???                                 7ff7a85f9476       kfun:kotlin.sequences.SequenceBuilderIterator.hasNext#internal + 278 
    at 6   ???                                 7ff7a8585b8a       kfun:kotlin.sequences#toList__at__kotlin.sequences.Sequence<0:0>(){0§<kotlin.Any?>}kotlin.collections.List<0:0> + 442 
    at 7   ???                                 7ff7a8889e71       kfun:com.saveourtool.save.plugins.fix.FixPlugin.handleFiles$lambda$3#internal + 10193 
    at 8   ???                                 7ff7a888ec86       kfun:com.saveourtool.save.plugins.fix.FixPlugin.$handleFiles$lambda$3$FUNCTION_REFERENCE$53.invoke#internal + 70 
    at 9   ???                                 7ff7a85fa441       kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 417 
    at 10  ???                                 7ff7a85fa494       kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 500 
    at 11  ???                                 7ff7a890c955       kfun:com.saveourtool.save.core.Save.executePlugin#internal + 981 
    at 12  ???                                 7ff7a890b468       kfun:com.saveourtool.save.core.Save#performAnalysis(){}com.saveourtool.save.core.reporter.Reporter + 6056 
    at 13  ???                                 7ff7a8915074       kfun:com.saveourtool.save.cli#main(kotlin.Array<kotlin.String>){} + 1732 
    at 14  ???                                 7ff7a894f8b7       Init_and_run_start + 503 
    at 15  ???                                 7ff7a894f9bf       Konan_main + 15 
    at 16  ???                                 7ff7a85613b4       __tmainCRTStartup + 564 
    at 17  ???                                 7ff7a856150b       mainCRTStartup + 27 
    at 18  ???                                 7ffc50237034       _ZSt25__throw_bad_function_callv + 19990731460 
    at 19  ???                                 7ffc509426a1       _ZSt25__throw_bad_function_callv + 19998118193 

Case 3: Linux, artifactLocation contains an absolute file: URI with an absolute path

Uncaught Kotlin exception: okio.FileNotFoundException: No such file or directory
    at 0   save                                0x557605           kfun:okio#errnoToIOException(kotlin.Int){}okio.IOException + 421
    at 1   save                                0x567066           kfun:okio#variantCanonicalize__at__okio.PosixFileSystem(okio.Path){}okio.Path + 614
    at 2   save                                0x766ccb           kfun:com.saveourtool.sarifutils.adapter.SarifFixAdapter.applyReplacementsToFiles#internal + 1259
    at 3   save                                0x768f5d           kfun:com.saveourtool.sarifutils.adapter.SarifFixAdapter.process$lambda$0#internal + 3949
    at 4   save                                0x4f97e0           kfun:kotlin.sequences.$flatMapIndexed$lambda$5COROUTINE$16.invokeSuspend#internal + 592
    at 5   save                                0x46bab0           kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 240
    at 6   save                                0x4f7b68           kfun:kotlin.sequences.SequenceBuilderIterator.hasNext#internal + 280
    at 7   save                                0x48522b           kfun:kotlin.sequences#toList__at__kotlin.sequences.Sequence<0:0>(){0§<kotlin.Any?>}kotlin.collections.List<0:0> + 443
    at 8   save                                0x772986           kfun:com.saveourtool.save.plugins.fix.FixPlugin.handleFiles$lambda$3#internal + 10118
    at 9   save                                0x7775ff           kfun:com.saveourtool.save.plugins.fix.FixPlugin.$handleFiles$lambda$3$FUNCTION_REFERENCE$53.invoke#internal + 63
    at 10  save                                0x4f8b40           kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 432
    at 11  save                                0x4f8b93           kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 515
    at 12  save                                0x7f1735           kfun:com.saveourtool.save.core.Save.executePlugin#internal + 965
    at 13  save                                0x7f0248           kfun:com.saveourtool.save.core.Save#performAnalysis(){}com.saveourtool.save.core.reporter.Reporter + 5976
    at 14  save                                0x7f9e69           kfun:com.saveourtool.save.cli#main(kotlin.Array<kotlin.String>){} + 1737
    at 15  save                                0x835527           Init_and_run_start + 503
    at 16  save                                0x83561a           Konan_main + 10
    at 17  libc.so.6                           0x7f265a14dd09     __libc_start_main + 233
    at 18  save                                0x461091           0x0 + 4591761

Case 4: Linux, artifactLocation contains an absolute file: URI with a relative path

Uncaught Kotlin exception: okio.FileNotFoundException: No such file or directory
    at 0   save                                0x557605           kfun:okio#errnoToIOException(kotlin.Int){}okio.IOException + 421
    at 1   save                                0x567066           kfun:okio#variantCanonicalize__at__okio.PosixFileSystem(okio.Path){}okio.Path + 614
    at 2   save                                0x766ccb           kfun:com.saveourtool.sarifutils.adapter.SarifFixAdapter.applyReplacementsToFiles#internal + 1259
    at 3   save                                0x768f5d           kfun:com.saveourtool.sarifutils.adapter.SarifFixAdapter.process$lambda$0#internal + 3949
    at 4   save                                0x4f97e0           kfun:kotlin.sequences.$flatMapIndexed$lambda$5COROUTINE$16.invokeSuspend#internal + 592
    at 5   save                                0x46bab0           kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 240
    at 6   save                                0x4f7b68           kfun:kotlin.sequences.SequenceBuilderIterator.hasNext#internal + 280
    at 7   save                                0x48522b           kfun:kotlin.sequences#toList__at__kotlin.sequences.Sequence<0:0>(){0§<kotlin.Any?>}kotlin.collections.List<0:0> + 443
    at 8   save                                0x772986           kfun:com.saveourtool.save.plugins.fix.FixPlugin.handleFiles$lambda$3#internal + 10118
    at 9   save                                0x7775ff           kfun:com.saveourtool.save.plugins.fix.FixPlugin.$handleFiles$lambda$3$FUNCTION_REFERENCE$53.invoke#internal + 63
    at 10  save                                0x4f8b40           kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 432
    at 11  save                                0x4f8b93           kfun:kotlin.sequences.FlatteningSequence.object-1.ensureItemIterator#internal + 515
    at 12  save                                0x7f1735           kfun:com.saveourtool.save.core.Save.executePlugin#internal + 965
    at 13  save                                0x7f0248           kfun:com.saveourtool.save.core.Save#performAnalysis(){}com.saveourtool.save.core.reporter.Reporter + 5976
    at 14  save                                0x7f9e69           kfun:com.saveourtool.save.cli#main(kotlin.Array<kotlin.String>){} + 1737
    at 15  save                                0x835527           Init_and_run_start + 503
    at 16  save                                0x83561a           Konan_main + 10
    at 17  libc.so.6                           0x7f95e90e0d09     __libc_start_main + 233
    at 18  save                                0x461091           0x0 + 4591761
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant