Skip to content

Commit 1f5e52e

Browse files
committed
Python: Cleanup "first" type-tracking predicate to be private
Since it's exposed nicely in the version that doesn't have a `DataFlow::TypeTracker` parameter, these should be private. Also found one instance where I had accidentially used DataFlow::Node instead of LocalSourceNode
1 parent a43bb1f commit 1f5e52e

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

python/ql/src/semmle/python/Concepts.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ module Cryptography {
563563
/** Provides classes for modeling new key-pair generation APIs. */
564564
module KeyGeneration {
565565
/** Gets a back-reference to the keysize argument `arg` that was used to generate a new key-pair. */
566-
DataFlow::LocalSourceNode keysizeBacktracker(DataFlow::TypeBackTracker t, DataFlow::Node arg) {
566+
private DataFlow::LocalSourceNode keysizeBacktracker(
567+
DataFlow::TypeBackTracker t, DataFlow::Node arg
568+
) {
567569
t.start() and
568570
arg = any(KeyGeneration::Range r).getKeySizeArg() and
569571
result = arg.getALocalSource()

python/ql/src/semmle/python/dataflow/new/TypeTracker.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private newtype TTypeTracker = MkTypeTracker(Boolean hasCall, OptionalAttributeN
180180
* It is recommended that all uses of this type are written in the following form,
181181
* for tracking some type `myType`:
182182
* ```
183-
* DataFlow::LocalSourceNode myType(DataFlow::TypeTracker t) {
183+
* private DataFlow::LocalSourceNode myType(DataFlow::TypeTracker t) {
184184
* t.start() and
185185
* result = < source of myType >
186186
* or
@@ -341,7 +341,7 @@ private newtype TTypeBackTracker = MkTypeBackTracker(Boolean hasReturn, Optional
341341
* for back-tracking some callback type `myCallback`:
342342
*
343343
* ```
344-
* DataFlow::LocalSourceNode myCallback(DataFlow::TypeBackTracker t) {
344+
* private DataFlow::LocalSourceNode myCallback(DataFlow::TypeBackTracker t) {
345345
* t.start() and
346346
* result = (< some API call >).getArgument(< n >).getALocalSource()
347347
* or

python/ql/src/semmle/python/frameworks/Cryptography.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private module CryptographyModel {
7676
}
7777

7878
/** Gets a reference to a predefined curve class instance with a specific key size (in bits), as well as the origin of the class. */
79-
private DataFlow::Node curveClassInstanceWithKeySize(
79+
private DataFlow::LocalSourceNode curveClassInstanceWithKeySize(
8080
DataFlow::TypeTracker t, int keySize, DataFlow::Node origin
8181
) {
8282
t.start() and

python/ql/test/experimental/dataflow/typetracking/moduleattr.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import python
22
import semmle.python.dataflow.new.DataFlow
33
import semmle.python.dataflow.new.TypeTracker
44

5-
DataFlow::LocalSourceNode module_tracker(TypeTracker t) {
5+
private DataFlow::LocalSourceNode module_tracker(TypeTracker t) {
66
t.start() and
77
result = DataFlow::importNode("module")
88
or
@@ -13,7 +13,7 @@ query DataFlow::Node module_tracker() {
1313
module_tracker(DataFlow::TypeTracker::end()).flowsTo(result)
1414
}
1515

16-
DataFlow::LocalSourceNode module_attr_tracker(TypeTracker t) {
16+
private DataFlow::LocalSourceNode module_attr_tracker(TypeTracker t) {
1717
t.startInAttr("attr") and
1818
result = module_tracker()
1919
or

python/ql/test/experimental/dataflow/typetracking/tracked.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import TestUtilities.InlineExpectationsTest
66
// -----------------------------------------------------------------------------
77
// tracked
88
// -----------------------------------------------------------------------------
9-
DataFlow::LocalSourceNode tracked(TypeTracker t) {
9+
private DataFlow::LocalSourceNode tracked(TypeTracker t) {
1010
t.start() and
1111
result.asCfgNode() = any(NameNode n | n.getId() = "tracked")
1212
or
@@ -34,14 +34,14 @@ class TrackedTest extends InlineExpectationsTest {
3434
// -----------------------------------------------------------------------------
3535
// int + str
3636
// -----------------------------------------------------------------------------
37-
DataFlow::LocalSourceNode int_type(TypeTracker t) {
37+
private DataFlow::LocalSourceNode int_type(TypeTracker t) {
3838
t.start() and
3939
result.asCfgNode() = any(CallNode c | c.getFunction().(NameNode).getId() = "int")
4040
or
4141
exists(TypeTracker t2 | result = int_type(t2).track(t2, t))
4242
}
4343

44-
DataFlow::LocalSourceNode string_type(TypeTracker t) {
44+
private DataFlow::LocalSourceNode string_type(TypeTracker t) {
4545
t.start() and
4646
result.asCfgNode() = any(CallNode c | c.getFunction().(NameNode).getId() = "str")
4747
or
@@ -83,7 +83,7 @@ class TrackedStringTest extends InlineExpectationsTest {
8383
// -----------------------------------------------------------------------------
8484
// tracked_self
8585
// -----------------------------------------------------------------------------
86-
DataFlow::LocalSourceNode tracked_self(TypeTracker t) {
86+
private DataFlow::LocalSourceNode tracked_self(TypeTracker t) {
8787
t.start() and
8888
exists(Function f |
8989
f.isMethod() and

0 commit comments

Comments
 (0)