-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Java: Ratpack HTTP Framework Additional Modeling #7007
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
Java: Ratpack HTTP Framework Additional Modeling #7007
Conversation
Click to show differences in coveragejavaGenerated file changes for java
- Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,99,151,,,,14,18,,
+ Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,239,151,,,,14,18,,
- Totals,,175,5332,408,13,6,10,107,33,1,66
+ Totals,,175,5472,408,13,6,10,107,33,1,66
- ratpack.exec,,,26,,,,,,,,,,,,,,,,,,,,,,26
+ ratpack.exec,,,58,,,,,,,,,,,,,,,,,,,,,,58
- ratpack.func,,,5,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.func,,,59,,,,,,,,,,,,,,,,,,,,,,59
- ratpack.util,,,5,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.util,,,59,,,,,,,,,,,,,,,,,,,,,,59 |
Noting I haven't forgotten this bug and intend to look at it Friday or Monday |
(Edit: apologies I had missed discussion between @atorralba and @aschackmull on this) |
I think the bulk of the code changes here are "done" but I'm waiting on a fix for the bug in order to request this to be merged. Could someone add the |
Bug should be fixed now (#7187), so you should be able to get things working using just |
c4f2d27
to
c079914
Compare
😆
Indeed! This does now work! The PR is updated! 😄 |
Click to show differences in coveragejavaGenerated file changes for java
- Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,99,151,,,,14,18,,
+ Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,177,151,,,,14,18,,
- Totals,,175,5369,431,13,6,10,107,33,1,66
+ Totals,,175,5447,431,13,6,10,107,33,1,66
- ratpack.exec,,,26,,,,,,,,,,,,,,,,,,,,,,,26
+ ratpack.exec,,,48,,,,,,,,,,,,,,,,,,,,,,,48
- ratpack.func,,,5,,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.func,,,33,,,,,,,,,,,,,,,,,,,,,,,33
- ratpack.util,,,5,,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.util,,,33,,,,,,,,,,,,,,,,,,,,,,,33 |
Click to show differences in coveragejavaGenerated file changes for java
- Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,99,151,,,,14,18,,
+ Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,177,151,,,,14,18,,
- Totals,,175,5369,431,13,6,10,107,33,1,66
+ Totals,,175,5447,431,13,6,10,107,33,1,66
- ratpack.exec,,,26,,,,,,,,,,,,,,,,,,,,,,,26
+ ratpack.exec,,,48,,,,,,,,,,,,,,,,,,,,,,,48
- ratpack.func,,,5,,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.func,,,33,,,,,,,,,,,,,,,,,,,,,,,33
- ratpack.util,,,5,,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.util,,,33,,,,,,,,,,,,,,,,,,,,,,,33 |
"pushLeft;(Object);;Argument[-1];" + right + " of ReturnValue;value", | ||
"pushRight;(Object);;Argument[-1];" + left + " of ReturnValue;value", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing: arg0 -> left/right of returnval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were indeed correct. Thank you for spotting this! I'm impressed with how thoroughly you check these PR's. I would have missed this as a reviewer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should now be fixed. See below.
"next;;;Argument[-1];ReturnValue;value", | ||
"nextOp;;;Element of Argument[-1];Parameter[0] of Argument[0];value", | ||
"flatOp;;;Element of Argument[-1];Parameter[0] of Argument[0];value", | ||
// `nextOpIf` accesses qualfier the 'Promise' value and also returns the qualifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// `nextOpIf` accesses qualfier the 'Promise' value and also returns the qualifier | |
// `nextOpIf` accesses qualifier the 'Promise' value and also returns the qualifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I blame GitHub copilot 😆
java/ql/lib/semmle/code/java/frameworks/ratpack/RatpackExec.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/frameworks/ratpack/RatpackExec.qll
Outdated
Show resolved
Hide resolved
// `blockingOp` passes the value to the argumet | ||
"blockingOp;;;Element of Argument[-1];Parameter[0] of Argument[0];value", | ||
// `replace` returns the passed `Promise` | ||
"replace;;;Argument[0];ReturnValue;value", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc and the source both read like you get a new promise back, that discards the outcome of this
and replaces it with the outcome of arg0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite, it's not discarding the promise, because everything earlier in the chain still needs to execute.
Here's how the method is implemented on the interface:
/**
* Replaces {@code this} promise with the provided promise for downstream subscribers.
* <p>
* This is simply a more convenient form of {@link #flatMap(Function)}, where the given promise is returned.
* This method can be used when a subsequent operation on a promise isn't dependent on the actual promised value.
* <p>
* If the upstream promise fails, its error will propagate downstream and the given promise will never be subscribed to.
*
* <pre class="java">{@code
* import ratpack.test.exec.ExecHarness;
* import ratpack.exec.ExecResult;
* import ratpack.exec.Promise;
*
* import static org.junit.Assert.assertEquals;
*
* public class Example {
* private static String value;
*
* public static void main(String... args) throws Exception {
* ExecResult<String> result = ExecHarness.yieldSingle(c ->
* Promise.value("foo")
* .next(v -> value = v)
* .replace(Promise.value("bar"))
* );
*
* assertEquals("bar", result.getValue());
* assertEquals("foo", value);
* }
* }
* }</pre>
*
* @param next the promise to replace {@code this} with
* @param <O> the type of the value of the replacement promise
* @return a promise
* @since 1.1
*/
default <O> Promise<O> replace(Promise<O> next) {
return flatMap(in -> next);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but that's a fresh object, so we don't have value-flow from next
to the return value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, sure, but the semantics are the same from a CodeQL perspective, are they not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we would call aliases value-flow and anything else taint-flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've updated this to be replace;;;Element of Argument[0];Element of ReturnValue;value
java/ql/lib/semmle/code/java/frameworks/ratpack/RatpackExec.qll
Outdated
Show resolved
Hide resolved
Adds models for `ratpack.func.Pair`, and `ratpack.exec.Result`. Improve moels for `ratpack.exec.Promise`. Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
5cc1d98
to
36bb84d
Compare
Click to show differences in coveragejavaGenerated file changes for java
- Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,99,151,,,,14,18,,
+ Others,"``cn.hutool.core.codec``, ``com.esotericsoftware.kryo.io``, ``com.esotericsoftware.kryo5.io``, ``com.fasterxml.jackson.core``, ``com.fasterxml.jackson.databind``, ``com.opensymphony.xwork2.ognl``, ``com.unboundid.ldap.sdk``, ``flexjson``, ``groovy.lang``, ``groovy.util``, ``jodd.json``, ``net.sf.saxon.s9api``, ``ognl``, ``org.apache.commons.codec``, ``org.apache.commons.jexl2``, ``org.apache.commons.jexl3``, ``org.apache.commons.ognl``, ``org.apache.directory.ldap.client.api``, ``org.apache.ibatis.jdbc``, ``org.apache.shiro.codec``, ``org.apache.shiro.jndi``, ``org.codehaus.groovy.control``, ``org.dom4j``, ``org.hibernate``, ``org.jooq``, ``org.mvel2``, ``org.xml.sax``, ``org.xmlpull.v1``, ``play.mvc``, ``ratpack.core.form``, ``ratpack.core.handling``, ``ratpack.core.http``, ``ratpack.exec``, ``ratpack.form``, ``ratpack.func``, ``ratpack.handling``, ``ratpack.http``, ``ratpack.util``",39,181,151,,,,14,18,,
- Totals,,175,5369,431,13,6,10,107,33,1,66
+ Totals,,175,5451,431,13,6,10,107,33,1,66
- ratpack.exec,,,26,,,,,,,,,,,,,,,,,,,,,,,26
+ ratpack.exec,,,48,,,,,,,,,,,,,,,,,,,,,,,48
- ratpack.func,,,5,,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.func,,,35,,,,,,,,,,,,,,,,,,,,,,,35
- ratpack.util,,,5,,,,,,,,,,,,,,,,,,,,,,,5
+ ratpack.util,,,35,,,,,,,,,,,,,,,,,,,,,,,35 |
I see that this is failing, but I can't see the failures because that repository is not public. |
I re-launched it because it seemed a transient error. Now it's all green. |
Adds models for
ratpack.func.Pair
, andratpack.exec.Result
.Improve models for
ratpack.exec.Promise
.