@@ -156,29 +156,28 @@ module NotExposed {
156
156
* ```
157
157
*/
158
158
predicate newDirectAlias (
159
- FindSubclassesSpec spec , string newAliasFullyQualified , ImportMember importMember , Module mod ,
160
- Location loc
159
+ FindSubclassesSpec spec , string newAliasFullyQualified , Expr value , Module mod , Location loc
161
160
) {
162
- importMember =
163
- newOrExistingModeling ( spec ) .getASubclass * ( ) .getAValueReachableFromSource ( ) .asExpr ( ) and
164
- importMember .getScope ( ) = mod and
165
- loc = importMember .getLocation ( ) and
166
- exists ( Alias alias , string base |
167
- mod .isPackageInit ( ) and base = mod .getPackageName ( )
168
- or
169
- not mod .isPackageInit ( ) and base = mod .getName ( )
170
- |
171
- alias . getValue ( ) = importMember and
172
- newAliasFullyQualified = base + "." + alias . getAsname ( )
173
- ) and
174
- (
175
- not hasAllStatement ( mod )
176
- or
177
- mod . declaredInAll ( importMember . getName ( ) )
178
- ) and
179
- not alreadyExplicitlyModeled ( spec , newAliasFullyQualified ) and
180
- not isTestCode ( importMember ) and
181
- isAllowedModule ( mod )
161
+ exists ( Alias alias | value = alias . getValue ( ) |
162
+ value = newOrExistingModeling ( spec ) .getASubclass * ( ) .getAValueReachableFromSource ( ) .asExpr ( ) and
163
+ value .getScope ( ) = mod and
164
+ loc = value .getLocation ( ) and
165
+ exists ( string base |
166
+ mod .isPackageInit ( ) and base = mod .getPackageName ( )
167
+ or
168
+ not mod .isPackageInit ( ) and base = mod .getName ( )
169
+ |
170
+ newAliasFullyQualified = base + "." + alias . getAsname ( ) . ( Name ) . getId ( )
171
+ ) and
172
+ (
173
+ not hasAllStatement ( mod )
174
+ or
175
+ mod . declaredInAll ( alias . getAsname ( ) . ( Name ) . getId ( ) )
176
+ ) and
177
+ not alreadyExplicitlyModeled ( spec , newAliasFullyQualified ) and
178
+ not isTestCode ( value ) and
179
+ isAllowedModule ( mod )
180
+ )
182
181
}
183
182
184
183
/**
@@ -191,11 +190,15 @@ module NotExposed {
191
190
string relevantName , Location loc
192
191
) {
193
192
loc = mod .getLocation ( ) and
194
- exists ( API:: Node relevantClass , Expr value |
193
+ exists ( API:: Node relevantClass , ControlFlowNode value |
195
194
relevantClass = newOrExistingModeling ( spec ) .getASubclass * ( ) and
196
195
ImportResolution:: module_export ( mod , relevantName , def ) and
197
- value = relevantClass .getAValueReachableFromSource ( ) .asExpr ( ) and
198
- value = def .asVar ( ) .getDefinition ( ) .( AssignmentDefinition ) .getValue ( ) .getNode ( )
196
+ value = relevantClass .getAValueReachableFromSource ( ) .asCfgNode ( ) and
197
+ (
198
+ value = def .asVar ( ) .getDefinition ( ) .( AssignmentDefinition ) .getValue ( )
199
+ or
200
+ value = def .asCfgNode ( )
201
+ )
199
202
// value could be a ClassExpr if a new class is defined, or a Name if defining an alias
200
203
) and
201
204
(
0 commit comments