File tree 4 files changed +141
-0
lines changed
regression/end_to_end/interprocedural00
4 files changed +141
-0
lines changed Original file line number Diff line number Diff line change
1
+ <project name =" interprocedural00" basedir =" ." default =" jar" >
2
+
3
+ <property name =" root.dir" value =" ./" />
4
+ <property name =" src.dir" value =" ${ root.dir } /src" />
5
+ <property name =" classes.dir" value =" ${ root.dir } /build" />
6
+ <property name =" install.dir" value =" ${ root.dir } /dist" />
7
+
8
+ <target name =" jar" >
9
+ <antcall target =" compile" />
10
+ <mkdir dir =" ${ install.dir } " />
11
+ <jar destfile =" ${ install.dir } /interprocedural00.jar" basedir =" ${ classes.dir } " />
12
+ </target >
13
+
14
+ <target name =" compile" >
15
+ <antcall target =" clean" />
16
+ <mkdir dir =" ${ classes.dir } " />
17
+ <javac srcdir =" ${ src.dir } " destdir =" ${ classes.dir } " includeantruntime =" false" debug =" on" >
18
+ </javac >
19
+ </target >
20
+
21
+ <target name =" clean" >
22
+ <delete dir =" ${ classes.dir } " />
23
+ <delete dir =" ${ install.dir } " />
24
+ </target >
25
+
26
+
27
+ </project >
28
+
29
+
Original file line number Diff line number Diff line change
1
+ {
2
+ "namespace" : " com.diffblue.security" ,
3
+ "rules" :
4
+ [
5
+ {
6
+ "comment" : " Obtaining a stream with potentially tainted data." ,
7
+ "class" : " Main" ,
8
+ "method" : " getInStream:()LIStream;" ,
9
+ "result" : {
10
+ "location" : " returns" ,
11
+ "taint" : " Tainted stream"
12
+ }
13
+ },
14
+ {
15
+ "comment" : " Obtaining a vulnerable stream" ,
16
+ "class" : " Main" ,
17
+ "method" : " getOutStream:()LOStream;" ,
18
+ "result" : {
19
+ "location" : " returns" ,
20
+ "vulnerability" : " Vulnerable stream"
21
+ }
22
+ },
23
+ {
24
+ "comment" : " Read from tainted stream gives tainted string" ,
25
+ "class" : " IStream" ,
26
+ "method" : " read:(LData;)V" ,
27
+ "input" : {
28
+ "location" : " this" ,
29
+ "taint" : " Tainted stream"
30
+ },
31
+ "result" : {
32
+ "location" : " arg1" ,
33
+ "taint" : " Tainted data"
34
+ }
35
+ },
36
+ {
37
+ "comment" : " Writing potentially tainted data to a vulnerable stream." ,
38
+ "class" : " OStream" ,
39
+ "method" : " write:(LData;)V" ,
40
+ "input" : {
41
+ "location" : " arg1" ,
42
+ "taint" : " Tainted data"
43
+ },
44
+ "sinkTarget" : {
45
+ "location" : " this" ,
46
+ "vulnerability" : " Vulnerable stream"
47
+ },
48
+ "message" : " Writing potentially tainted data to a vulnerable stream."
49
+ }
50
+ ]
51
+ }
52
+
53
+
Original file line number Diff line number Diff line change
1
+ class Data {
2
+ }
3
+
4
+ class IStream {
5
+ public void read (Data d ) {
6
+ }
7
+ }
8
+
9
+ class OStream {
10
+ public void write (Data d ) {
11
+ }
12
+ }
13
+
14
+ public class Main {
15
+
16
+ public static IStream getInStream () {
17
+ return new IStream ();
18
+ }
19
+
20
+ public static OStream getOutStream () {
21
+ return new OStream ();
22
+ }
23
+
24
+ public static Data getData () {
25
+ return new Data ();
26
+ }
27
+
28
+ private static void getBytes (Data data , IStream in ) {
29
+ in .read (data );
30
+ }
31
+
32
+ private static void postBytes (Data data , OStream out ) {
33
+ out .write (data );
34
+ }
35
+
36
+ public static void main () {
37
+ IStream in = getInStream ();
38
+ OStream out = getOutStream ();
39
+ Data d = getData ();
40
+ getBytes (d , in );
41
+ postBytes (d , out );
42
+ }
43
+
44
+ }
45
+
Original file line number Diff line number Diff line change
1
+ import regression .end_to_end .driver as pipeline_executor
2
+ import os
3
+ import subprocess
4
+
5
+
6
+ def test_interprocedural00 ():
7
+ with pipeline_executor .working_dir (os .path .abspath (os .path .dirname (__file__ ))):
8
+ subprocess .call ("ant" )
9
+ traces = pipeline_executor .run_security_analyser_pipeline (
10
+ os .path .join ("dist" , "interprocedural00.jar" ),
11
+ "rules.json" ,
12
+ os .path .realpath (os .path .dirname (__file__ )))
13
+ assert traces .count_traces () == 1
14
+ assert traces .trace_exists ("java::Main.postBytes:(LData;LOStream;)V" , 33 )
You can’t perform that action at this time.
0 commit comments