Skip to content

[java-source-utils] Fix lgtm java/path-injection-local #1079

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

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

jonpryor
Copy link
Contributor

@jonpryor jonpryor commented Jan 27, 2023

Context: e11d024

Commit e11d024 attempted to fix LGTM-reported
java/path-injection-local warnings by using the comment // lgtm [java/path-injection-local].

Unfortunately, this is insufficient: the comment also needs to provide a 25+ character justification for why the offending statement can be ignored. This justification was not provided.

Update the // lgtm [java/path-injection-local] comments to provide a justification, as required by tooling.

Copying the longer justification from e11d024:

LGTM is complaining that tools/java-source-utils (69e1b80) accepts
user-controlled data. These warnings will be ignored because the
app is unusable without "user-controlled data"

These are all user-controlled, and they are necessary to allow
java-source-utils to work.

LGTM complains that --output-javadoc FILE accepts a user-controlled
path which may [contain] directory separator chars, and
this is intentional; using it would be annoying if that weren't true!

See also JavaSourceUtils.cs, which passes a value located within $(IntermediateOutputPath) to
java-source-utils.jar --output-javadoc. Allowing --output-javadoc to contain directory separator chars is what makes this possible!

Context: e11d024

Commit e11d024 attempted to fix LGTM-reported
[`java/path-injection-local`][0] warnings by using the comment
`// lgtm [java/path-injection-local]`.

Unfortunately, this is insufficient: the comment *also* needs to
provide a 25+ character justification for why the offending statement
can be ignored.  This justification was not provided.

Update the `// lgtm [java/path-injection-local]` comments to provide
a justification, as required by tooling.

Copying the longer justification from e11d024:

> LGTM is complaining that `tools/java-source-utils` (69e1b80) accepts
> user-controlled data.  These warnings will be *ignored* because the
> app is *unusable* without "user-controlled data"
> …
> These are all user-controlled, and they are necessary to allow
> `java-source-utils` to *work*.
> …
> LGTM complains that `--output-javadoc FILE` accepts a user-controlled
> path which may [contain] directory separator chars, and
> *this is intentional*; using it would be annoying if that weren't true!

See also [`JavaSourceUtils.cs`][1], which passes [a value][2] located
within `$(IntermediateOutputPath)` to
`java-source-utils.jar --output-javadoc`.  Allowing `--output-javadoc`
to contain directory separator chars is what makes this possible!

[0]: https://github.com/github/codeql/blob/f192191e8c4c14d70a86342de47c8882516c7c25/java/ql/src/Security/CWE/CWE-022/TaintedPath.qhelp
[1]: https://github.com/xamarin/xamarin-android/blob/b00185c485287c2c5f0350a067ebc178aec2382c/src/Xamarin.Android.Build.Tasks/Tasks/JavaSourceUtils.cs#L134-L135
[2]: https://github.com/xamarin/xamarin-android/blob/b00185c485287c2c5f0350a067ebc178aec2382c/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets#L69
@jonpryor jonpryor force-pushed the jonp-lgtm-2023-01-26 branch from 0a9da6c to a3b6d13 Compare January 27, 2023 01:41
@jonpryor jonpryor merged commit 5fa7ac4 into dotnet:main Jan 27, 2023
jonpryor pushed a commit to dotnet/android that referenced this pull request Feb 15, 2023
Changes: dotnet/java-interop@8a1ae57...9e0a469

  * dotnet/java-interop@9e0a4690: [generator] deep clone methods to avoid NREs (dotnet/java-interop#1080)
  * dotnet/java-interop@5fa7ac45: [java-source-utils] Fix lgtm java/path-injection-local (dotnet/java-interop#1079)
  * dotnet/java-interop@120d8a71: [generator] Add more [ObsoleteOSPlatform] to prevent CA1422 (dotnet/java-interop#1078)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant