Skip to content

Commit de5ec1f

Browse files
authored
Merge branch 'main' into aegilops/polyfill-io-compromised-script
2 parents 79980a9 + 1de2943 commit de5ec1f

File tree

4 files changed

+43
-29
lines changed

4 files changed

+43
-29
lines changed

python/extractor/semmle/logging.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ def syntax_error_message(exception, unit):
373373
return error
374374

375375
def recursion_error_message(exception, unit):
376-
l = Location(file=unit.path)
376+
# if unit is a BuiltinModuleExtractable, there will be no path attribute
377+
l = Location(file=unit.path) if hasattr(unit, "path") else None
377378
return (DiagnosticMessage(Source("py/diagnostics/recursion-error", "Recursion error in Python extractor"), Severity.ERROR)
378379
.with_location(l)
379380
.text(exception.args[0])
@@ -383,7 +384,8 @@ def recursion_error_message(exception, unit):
383384
)
384385

385386
def internal_error_message(exception, unit):
386-
l = Location(file=unit.path)
387+
# if unit is a BuiltinModuleExtractable, there will be no path attribute
388+
l = Location(file=unit.path) if hasattr(unit, "path") else None
387389
return (DiagnosticMessage(Source("py/diagnostics/internal-error", "Internal error in Python extractor"), Severity.ERROR)
388390
.with_location(l)
389391
.text("Internal error")

python/extractor/semmle/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#Semantic version of extractor.
1212
#Update this if any changes are made
13-
VERSION = "6.1.1"
13+
VERSION = "6.1.2"
1414

1515
PY_EXTENSIONS = ".py", ".pyw"
1616

python/extractor/semmle/worker.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,24 @@ def _extract_loop(proc_id, queue, trap_dir, archive, options, reply_queue, logge
274274
# Syntax errors have already been handled in extractor.py
275275
reply_queue.put(("FAILURE", unit, None))
276276
except RecursionError as ex:
277-
error = recursion_error_message(ex, unit)
278-
diagnostics_writer.write(error)
279277
logger.error("Failed to extract %s: %s", unit, ex)
280278
logger.traceback(WARN)
279+
try:
280+
error = recursion_error_message(ex, unit)
281+
diagnostics_writer.write(error)
282+
except Exception as ex:
283+
logger.warning("Failed to write diagnostics: %s", ex)
284+
logger.traceback(WARN)
281285
reply_queue.put(("FAILURE", unit, None))
282286
except Exception as ex:
283-
error = internal_error_message(ex, unit)
284-
diagnostics_writer.write(error)
285287
logger.error("Failed to extract %s: %s", unit, ex)
286288
logger.traceback(WARN)
289+
try:
290+
error = internal_error_message(ex, unit)
291+
diagnostics_writer.write(error)
292+
except Exception as ex:
293+
logger.warning("Failed to write diagnostics: %s", ex)
294+
logger.traceback(WARN)
287295
reply_queue.put(("FAILURE", unit, None))
288296
else:
289297
reply_queue.put(("SUCCESS", unit, None))

shared/ssa/codeql/ssa/Ssa.qll

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,31 +1322,27 @@ module Make<LocationSig Location, InputSig<Location> Input> {
13221322
}
13231323
}
13241324

1325-
private module Cached {
1326-
cached
1327-
newtype TNode =
1328-
TParamNode(DfInput::Parameter p) { DfInput::ssaDefInitializesParam(_, p) } or
1329-
TExprNode(DfInput::Expr e, Boolean isPost) {
1330-
e = DfInput::getARead(_)
1331-
or
1332-
DfInput::ssaDefAssigns(_, e) and
1325+
cached
1326+
private DefinitionExt getAPhiInputDef(SsaInputDefinitionExt phi, BasicBlock bb) {
1327+
phi.hasInputFromBlock(result, _, _, _, bb)
1328+
}
1329+
1330+
private newtype TNode =
1331+
TParamNode(DfInput::Parameter p) {
1332+
exists(WriteDefinition def | DfInput::ssaDefInitializesParam(def, p))
1333+
} or
1334+
TExprNode(DfInput::Expr e, Boolean isPost) {
1335+
e = DfInput::getARead(_)
1336+
or
1337+
exists(DefinitionExt def |
1338+
DfInput::ssaDefAssigns(def, e) and
13331339
isPost = false
1334-
} or
1335-
TSsaDefinitionNode(DefinitionExt def) or
1336-
TSsaInputNode(SsaInputDefinitionExt def, BasicBlock input) {
1337-
def.hasInputFromBlock(_, _, _, _, input)
1338-
}
1339-
1340-
cached
1341-
Definition getAPhiInputDef(SsaInputNode n) {
1342-
exists(SsaInputDefinitionExt phi, BasicBlock bb |
1343-
phi.hasInputFromBlock(result, _, _, _, bb) and
1344-
n.isInputInto(phi, bb)
13451340
)
1341+
} or
1342+
TSsaDefinitionNode(DefinitionExt def) or
1343+
TSsaInputNode(SsaInputDefinitionExt phi, BasicBlock input) {
1344+
exists(getAPhiInputDef(phi, input))
13461345
}
1347-
}
1348-
1349-
private import Cached
13501346

13511347
/**
13521348
* A data flow node that we need to reference in the value step relation.
@@ -1627,6 +1623,14 @@ module Make<LocationSig Location, InputSig<Location> Input> {
16271623
*/
16281624
signature predicate guardChecksSig(DfInput::Guard g, DfInput::Expr e, boolean branch);
16291625

1626+
pragma[nomagic]
1627+
private Definition getAPhiInputDef(SsaInputNode n) {
1628+
exists(SsaInputDefinitionExt phi, BasicBlock bb |
1629+
result = getAPhiInputDef(phi, bb) and
1630+
n.isInputInto(phi, bb)
1631+
)
1632+
}
1633+
16301634
/**
16311635
* Provides a set of barrier nodes for a guard that validates an expression.
16321636
*

0 commit comments

Comments
 (0)