Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Relocate Java CWE libraries to importable location #3923

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

Closed
wants to merge 5 commits into from

Conversation

rvermeulen
Copy link
Contributor

Multiple Java CWE queries use libraries that define source and sink nodes or other abstract classes of interest.
However, customisations cannot extend the CWE queries by defining new source or sink nodes due to the location of these libraries (i.e., their location CWE- contains a hyphen and cannot be imported).

This PR tracks the effort of relocating these 'extension points' to a location that can be imported by customisations to extend these queries without having to resort to QL code duplication.

@rvermeulen rvermeulen requested a review from a team as a code owner July 8, 2020 11:34
@rvermeulen rvermeulen marked this pull request as draft July 8, 2020 11:37
@intrigus-lgtm
Copy link
Contributor

intrigus-lgtm commented Jul 8, 2020

A little part of this is similar to my PR #3881
(The PathCreation stuff)

@rvermeulen
Copy link
Contributor Author

A little part of this is similar to my PR #3881
(The PathCreation stuff)

Thanks for the update. Seems like your PR covers the PathCreation part so I will update this PR before a merge.

@aibaars
Copy link
Contributor

aibaars commented Jul 8, 2020

This looks like a good approach. Could you make the naming of those new library files consistent? Some have a Lib suffix while others don't. Personally I'd drop the Lib bit.

@rvermeulen
Copy link
Contributor Author

This looks like a good approach. Could you make the naming of those new library files consistent? Some have a Lib suffix while others don't. Personally I'd drop the Lib bit.

I have dropped the Lib suffix from the new libraries.

@rvermeulen rvermeulen marked this pull request as ready for review July 8, 2020 13:08
@aschackmull
Copy link
Contributor

ResponseSplittingLocal.ql and UrlRedirectLocal.ql don't compile, hence the PR check failure.

@rvermeulen
Copy link
Contributor Author

rvermeulen commented Jul 8, 2020

ResponseSplittingLocal.ql and UrlRedirectLocal.ql don't compile, hence the PR check failure.

Was just about the ask about the failing Pull-Request-Check.
Will look into those.

It seems that they are not covered by a unit test.
Will see if I can add those.

Both `ResponseSplittingLocal.ql` and `UrlRedirectLocal.ql` referenced
the original library location instead of the new location.
Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

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

The SqlInjection[Lib].qll file should not be exposed in its entirety. It should be split in two files with the configuration and the queryTaintedBy predicate kept in a .qll next to the queries. Furthermore, once the top half of the file becomes importable we should make sure that it starts with import java as the very first import (and remove the subsequently superfluous import semmle.code.java.Expr).

@aschackmull
Copy link
Contributor

Which parts of LdapInjection[Lib].qll are expected to be reusable?

@rvermeulen
Copy link
Contributor Author

rvermeulen commented Jul 8, 2020

The SqlInjection[Lib].qll file should not be exposed in its entirety. It should be split in two files with the configuration and the queryTaintedBy predicate kept in a .qll next to the queries. Furthermore, once the top half of the file becomes importable we should make sure that it starts with import java as the very first import (and remove the subsequently superfluous import semmle.code.java.Expr).

This what I would like to discover through this PR. In the other libraries there are also private predicates that I would like to split out, but haven't yet because I wanted first to validate the approach.

The end-goal would be to only have extensible elements in these libraries.

@rvermeulen
Copy link
Contributor Author

rvermeulen commented Jul 8, 2020

Which parts of LdapInjection[Lib].qll are expected to be reusable?

The goal was the LdapInjectionSink, but I have to reconsider my assessment because it is not an abstract class.

@aschackmull
Copy link
Contributor

The goal was the LdapInjectionSink, but I have to reconsider my assessment because it is not an abstract class.

In that case, consider splitting the file such that the query specific parts are moved to the query and the sink is refactored as an importable abstract class.

@aschackmull
Copy link
Contributor

This what I would like to discover through this PR. In the other libraries there are also private predicates that I would like to split out, but haven't yet because I wanted first to validate the approach.

The approach is fine, it just needs individual care and attention for each query, as we don't necessarily want to expose everything, and once we expose something the quality requirements to the QL code goes up.

@aschackmull
Copy link
Contributor

(I've only reviewed a few of the files - I have a lot more review comments coming)

@rvermeulen
Copy link
Contributor Author

This what I would like to discover through this PR. In the other libraries there are also private predicates that I would like to split out, but haven't yet because I wanted first to validate the approach.

The approach is fine, it just needs individual care and attention for each query, as we don't necessarily want to expose everything, and once we expose something the quality requirements to the QL code goes up.

Given that, I will continue and ensure that only the extensible parts remain in the libraries to prevent unnecessary exposure.

@aschackmull
Copy link
Contributor

Given the scope of this, perhaps it would be easier to review and merge if we split this up into several PRs - with one PR for each CWE directory?

@rvermeulen
Copy link
Contributor Author

Given the scope of this, perhaps it would be easier to review and merge if we split this up into several PRs - with one PR for each CWE directory?

Sounds good. I will split it up in a PR per CWE directory.

@aschackmull
Copy link
Contributor

Sounds good. I will split it up in a PR per CWE directory.

Minor convenience thing: Please include "Java: " as a prefix in the PR titles.

@rvermeulen
Copy link
Contributor Author

This PR will be split into one PR per CWE directory.

@rvermeulen rvermeulen closed this Jul 8, 2020
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.

4 participants