Skip to content

Java: Factor out string prefix logic#6859

Merged
aschackmull merged 7 commits into
github:mainfrom
smowton:smowton/admin/factor-string-prefix
Oct 19, 2021
Merged

Java: Factor out string prefix logic#6859
aschackmull merged 7 commits into
github:mainfrom
smowton:smowton/admin/factor-string-prefix

Conversation

@smowton
Copy link
Copy Markdown
Contributor

@smowton smowton commented Oct 12, 2021

An external contributor wants to re-use this logic, so here I factor it out to permit customisation with a different class of interesting prefix strings.

@smowton smowton requested a review from a team as a code owner October 12, 2021 16:10
@github-actions github-actions Bot added the Java label Oct 12, 2021
@@ -0,0 +1,151 @@
/**
* Provides classes and predicates for identifying expressions that may be appended to an interesting prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This toplevel qldoc would really benefit from a Java code example to explain what's being identified where.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Extended the docs

private import semmle.code.java.StringFormat

/**
* A string constant that contains a prefix whose possible successor strings are returned
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The term "successor string" sounds weird. Could we be more precise? E.g.

Suggested change
* A string constant that contains a prefix whose possible successor strings are returned
* A string constant that contains a prefix whose potentially appended suffix strings are returned

* A string constant that contains a prefix whose possible successor strings are returned
* by `getAnAppendedExpression`.
*
* Extend this class to specify prefixes whose successors should be analysed.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/successors/??/

*/

import java
import semmle.code.java.dataflow.TaintTracking
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
import semmle.code.java.dataflow.TaintTracking
private import semmle.code.java.dataflow.TaintTracking

@smowton smowton force-pushed the smowton/admin/factor-string-prefix branch from 6d1e4c8 to d46b897 Compare October 19, 2021 10:32
@smowton
Copy link
Copy Markdown
Contributor Author

smowton commented Oct 19, 2021

@aschackmull comments applied

@aschackmull aschackmull merged commit 662852b into github:main Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants