Skip to content

Commit d1a23ad

Browse files
Jami CogswellJami Cogswell
authored andcommitted
updated to getRelativePath with %build%
1 parent 15df392 commit d1a23ad

File tree

3 files changed

+40
-36
lines changed

3 files changed

+40
-36
lines changed

java/ql/src/Security/CWE/CWE-489/DebuggableAttributeEnabled.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ from AndroidXmlAttribute androidXmlAttr
1717
where
1818
androidXmlAttr.getName() = "debuggable" and
1919
androidXmlAttr.getValue() = "true" and
20-
not androidXmlAttr.getLocation().getFile().getRelativePath().matches("%/build%")
20+
not androidXmlAttr.getLocation().getFile().getRelativePath().matches("%build%")
2121
select androidXmlAttr, "The 'android:debuggable' attribute is enabled."

java/ql/test/query-tests/security/CWE-489/DebuggableAttributeEnabledTest.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DebuggableAttributeTrueTest extends InlineExpectationsTest {
1212
exists(AndroidXmlAttribute androidXmlAttr |
1313
androidXmlAttr.getName() = "debuggable" and
1414
androidXmlAttr.getValue() = "true" and
15-
not androidXmlAttr.getLocation().getFile().getRelativePath().matches("%/build%")
15+
not androidXmlAttr.getLocation().getFile().getRelativePath().matches("%build%")
1616
|
1717
androidXmlAttr.getLocation() = location and
1818
element = androidXmlAttr.toString() and
Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1-
package com.example.myapp;
1+
public class Test {
22

3-
import android.app.Fragment;
4-
import android.os.Bundle;
5-
import android.view.LayoutInflater;
6-
import android.view.View;
7-
import android.view.ViewGroup;
8-
import android.widget.Button;
9-
import androidx.fragment.app.FragmentActivity;
10-
import androidx.fragment.app.FragmentTransaction;
3+
}
114

12-
public class Test extends FragmentActivity {
5+
// package com.example.myapp;
136

14-
@Override
15-
public void onCreate(Bundle savedInstance) {
16-
try {
17-
super.onCreate(savedInstance);
18-
final String fname = getIntent().getStringExtra("fname");
19-
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
20-
Class<Fragment> fClass = (Class<Fragment>) Class.forName(fname);
21-
ft.add(fClass.newInstance(), ""); // hasTaintFlow
22-
ft.add(0, Fragment.instantiate(this, fname), null); // hasTaintFlow
23-
ft.add(0, Fragment.instantiate(this, fname, null)); // hasTaintFlow
24-
ft.add(0, fClass, null, ""); // hasTaintFlow
25-
ft.add(0, fClass.newInstance(), ""); // hasTaintFlow
26-
ft.attach(fClass.newInstance()); // hasTaintFlow
27-
ft.replace(0, fClass, null); // hasTaintFlow
28-
ft.replace(0, fClass.newInstance()); // hasTaintFlow
29-
ft.replace(0, fClass, null, ""); // hasTaintFlow
30-
ft.replace(0, fClass.newInstance(), ""); // hasTaintFlow
7+
// import android.app.Fragment;
8+
// import android.os.Bundle;
9+
// import android.view.LayoutInflater;
10+
// import android.view.View;
11+
// import android.view.ViewGroup;
12+
// import android.widget.Button;
13+
// import androidx.fragment.app.FragmentActivity;
14+
// import androidx.fragment.app.FragmentTransaction;
3115

32-
ft.add(Fragment.class.newInstance(), ""); // Safe
33-
ft.attach(Fragment.class.newInstance()); // Safe
34-
ft.replace(0, Fragment.class.newInstance(), ""); // Safe
35-
} catch (Exception e) {
36-
}
37-
}
16+
// public class Test extends FragmentActivity {
3817

39-
}
18+
// @Override
19+
// public void onCreate(Bundle savedInstance) {
20+
// try {
21+
// super.onCreate(savedInstance);
22+
// final String fname = getIntent().getStringExtra("fname");
23+
// FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
24+
// Class<Fragment> fClass = (Class<Fragment>) Class.forName(fname);
25+
// ft.add(fClass.newInstance(), ""); // hasTaintFlow
26+
// ft.add(0, Fragment.instantiate(this, fname), null); // hasTaintFlow
27+
// ft.add(0, Fragment.instantiate(this, fname, null)); // hasTaintFlow
28+
// ft.add(0, fClass, null, ""); // hasTaintFlow
29+
// ft.add(0, fClass.newInstance(), ""); // hasTaintFlow
30+
// ft.attach(fClass.newInstance()); // hasTaintFlow
31+
// ft.replace(0, fClass, null); // hasTaintFlow
32+
// ft.replace(0, fClass.newInstance()); // hasTaintFlow
33+
// ft.replace(0, fClass, null, ""); // hasTaintFlow
34+
// ft.replace(0, fClass.newInstance(), ""); // hasTaintFlow
35+
36+
// ft.add(Fragment.class.newInstance(), ""); // Safe
37+
// ft.attach(Fragment.class.newInstance()); // Safe
38+
// ft.replace(0, Fragment.class.newInstance(), ""); // Safe
39+
// } catch (Exception e) {
40+
// }
41+
// }
42+
43+
// }

0 commit comments

Comments
 (0)