File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
python/ql/lib/semmle/python Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ private predicate legalDottedName(string name) {
177
177
}
178
178
179
179
bindingset [ name]
180
- private predicate legalShortName ( string name ) { name .regexpMatch ( "(\\p{L}|_)(\\p{L}|\\d|_)*" ) }
180
+ predicate legalShortName ( string name ) { name .regexpMatch ( "(\\p{L}|_)(\\p{L}|\\d|_)*" ) }
181
181
182
182
private string moduleNameFromBase ( Container file ) {
183
183
// We used to also require `isPotentialPackage(f)` to hold in this case,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ private import semmle.python.dataflow.new.DataFlow
10
10
private import semmle.python.dataflow.new.internal.ImportResolution
11
11
private import semmle.python.ApiGraphs
12
12
private import semmle.python.filters.Tests
13
+ private import semmle.python.Module
13
14
14
15
// very much inspired by the draft at https://github.com/github/codeql/pull/5632
15
16
module NotExposed {
@@ -114,7 +115,11 @@ module NotExposed {
114
115
predicate isAllowedModule ( Module mod ) {
115
116
// don't include anything found in site-packages
116
117
exists ( mod .getFile ( ) .getRelativePath ( ) ) and
117
- not mod .getFile ( ) .getRelativePath ( ) .regexpMatch ( "(?i)(^|/)examples?/.*" )
118
+ not mod .getFile ( ) .getRelativePath ( ) .regexpMatch ( "(?i)(^|/)examples?/.*" ) and
119
+ // to counter things like `my-example/app/foo.py` being allowed under `app.foo`
120
+ forall ( string part | part = mod .getFile ( ) .getParent ( ) .getRelativePath ( ) .splitAt ( "/" ) |
121
+ legalShortName ( part )
122
+ )
118
123
}
119
124
120
125
predicate isTestCode ( AstNode ast ) {
You can’t perform that action at this time.
0 commit comments