[go: nahoru, domu]

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

Unable to upload SARIF file #418

Open
aetos382 opened this issue Mar 12, 2021 · 9 comments
Open

Unable to upload SARIF file #418

aetos382 opened this issue Mar 12, 2021 · 9 comments

Comments

@aetos382
Copy link

When I attempted to upload a sarif file using the upload-sarif@v1 action, I encountered the following error.

Unable to upload "/home/runner/work/path-to.sarif" as it is not valid SARIF:
- instance.runs[0].tool.driver.language does not match pattern "^[a-zA-Z]{2}|^[a-zA-Z]{2}-[a-zA-Z]{2}]?$"

The language property of my sarif file is ja-JP, which is a valid form of language tag, but it did not match the regular expression pattern described above.

I think the regular expression pattern for this schema is a mistake.

"pattern": "^[a-zA-Z]{2}|^[a-zA-Z]{2}-[a-zA-Z]{2}]?$"

I think this schema is coming from https://github.com/oasis-tcs/sarif-spec .
So, I'm submitting an issue to that repository as well.
oasis-tcs/sarif-spec#488

@aeisenberg
Copy link
Contributor

Yes, that does seem suspicious. For now, can you change the language property to ja? I will investigate further.

@aeisenberg
Copy link
Contributor

Apologies for not following up until now. I think the pattern we would want to use is this: ^[a-zA-Z]{2}(-[a-zA-Z]{2})?$.

@lcartey, does this look right to you?

@aetos382
Copy link
Author
aetos382 commented Apr 9, 2021

@aeisenberg

For now, can you change the language property to ja?

My sarif file was generated by the C# compiler, so I can't change the language tag.

I have now disabled this action in my workflow, as it was not important for my project to use the compiler generated sarif file.

I think the pattern we would want to use is this: ^[a-zA-Z]{2}(-[a-zA-Z]{2})?$

Yes. I also think that pattern is correct.

aeisenberg added a commit to aeisenberg/sarif-spec that referenced this issue Apr 9, 2021
aeisenberg added a commit that referenced this issue Apr 9, 2021
See oasis-tcs/sarif-spec#490
See #418

Note that this changes the sarif spec file. Unless this
change is actually merged in the sarif spec repo, the
version used by the action will be slightly different.
aeisenberg added a commit that referenced this issue Apr 14, 2021
See oasis-tcs/sarif-spec#490
See #418

Note that this changes the sarif spec file. Unless this
change is actually merged in the sarif spec repo, the
version used by the action will be slightly different.
aofaof0907 pushed a commit to aofaof0907/codeql-action that referenced this issue Jul 29, 2021
See oasis-tcs/sarif-spec#490
See github#418

Note that this changes the sarif spec file. Unless this
change is actually merged in the sarif spec repo, the
version used by the action will be slightly different.
@stephenfuqua
Copy link

Still getting this error with release 2.9.4. My situation is also using a sarif file generated by the package Microsoft.CodeAnalysis in a .NET project. Example build failure. Locally I see that the sarif file has "en-US" for the language. I will continue to investigate as time is available, to see if I can find a workaround on my side or find and report on the root cause.

@aeisenberg
Copy link
Contributor

Hmmmm...The regex ^[a-zA-Z]{2}(-[a-zA-Z]{2})?$ does match en-US. Is it possible that instance.runs[0].tool.driver.language the value at is actually something different? Or possibly that the sarif generated on Actions is different from the one generated locally?

The sarif file being uploaded is src/EdFi.AnalyticsMiddleTier.Console/results.sarif. Any chance you can grab that and send it over to me?

@stephenfuqua
Copy link

Tomorrow I can try to upload the artifact in the repo so that we can see the actual file generated in GitHub, and I may be able to spend a few minutes digging in further with the codeql code. Here's a locally-generated file:

{
  "$schema": "http://json.schemastore.org/sarif-2.1.0",
  "version": "2.1.0",
  "runs": [
    {
      "results": [
      ],
      "tool": {
        "driver": {
          "name": "Microsoft (R) Visual C# Compiler",
          "version": "4.2.0-4.22220.5 (432d17a8)",
          "dottedQuadFileVersion": "4.2.0.0",
          "semanticVersion": "4.2.0",
          "language": "en-US"
        }
      },
      "columnKind": "utf16CodeUnits"
    }
  ]
}

@stephenfuqua
Copy link
stephenfuqua commented Jun 21, 2022

How interesting: the exact same dotnet application produces a sarif file with this, when run on GitHub Actions:

"language": "",

Which is obviously problematic. I will look into that further on the .NET side and submit a ticket in the proper .NET repository if needed. For the upload process, clearly there is a workaround: open the file and inject a valid language into it! And then 🤞 hopefully nothing else turns up.

@niederee
Copy link

@aetos382
Copy link
Author
aetos382 commented Jul 4, 2023

@stephenfuqua @niederee
Roslyn no longer outputs empty language property.
dotnet/roslyn#68745

You can also specify a <PreferredUILang> property to specify the language property values explicitly.

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

No branches or pull requests

4 participants