console: map PYTHONSRC to the ImportCode member named python by Portll · Pull Request #6243 · joernio/joern · GitHub
Skip to content

console: map PYTHONSRC to the ImportCode member named python - #6243

Merged
max-leuthaeuser merged 2 commits into
joernio:masterfrom
Portll:fix/pythonsrc-importcode-member
Sep 7, 2026
Merged

max-leuthaeuser merged 2 commits into
joernio:masterfrom
Portll:fix/pythonsrc-importcode-member

Conversation

@Portll

@Portll Portll commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

languageFromConfig already carries a table for the case where a Languages value and its ImportCode member name differ — JAVASRC is special-cased to "java" because ImportCode exposes it as def java. PYTHONSRC was missed, so it falls through to lang.toLowerCase and the generated script says importCode.pythonsrc.

The compiler names the fix itself:

value pythonsrc is not a member of io.joern.console.cpgcreation.ImportCode[...]
  - did you mean io.joern.console.cpgcreation.ImportCode[...].python?

This is the default path, not an opt-in

cpgcreation/package.scala returns Some(Languages.PYTHONSRC) for any file ending .py, and ImportCode.scala binds that same value to the member python. So auto-detection — what joern-scan <dir> does with no --language — produces the one spelling that does not compile. Every Python repository fails to scan.

Reproducer

Measured against joern 4.0.610 (Homebrew, macOS arm64, JDK 25):

mkdir -p /tmp/src && printf 'import os\ndef bad(p):\n    os.system("ls " + p)\n' > /tmp/src/v.py
joern-scan /tmp/src --overwrite --tags all
#   /tmp/joern-scan-log.txt:
#     importCode.pythonsrc("/tmp/src")
#     value pythonsrc is not a member of ... - did you mean ....python?
#     error during script execution: Error during compilation

On a stock launcher that failure arrives as exit 0 with the log banner as the only output, so a caller reads it as a clean scan of a repository with no findings. That amplifier is #6237; this is one of the faults it was hiding.

I checked the other members against their Languages values while I was in there — kotlin, golang, csharpsrc, php, abap all agree. Python was the only remaining gap.

Not measured

There is no sbt on this machine, so I have not compiled this. The one-line change follows the JAVASRC line directly above it, and the failure it fixes is measured on the released distribution, but the after state is an expectation rather than something I watched. scalafmt --test passes with the repo's pinned 3.8.1 — the formatting is scalafmt's own output, not hand-matched.

Closes: #5708

languageFromConfig already carries a table for the case where a Languages value and its ImportCode
member name differ -- JAVASRC is special-cased to "java" because ImportCode exposes it as `def java`.
PYTHONSRC was missed, so it falls through to lang.toLowerCase and the generated script says
`importCode.pythonsrc`, which is not a member. Every Python repository fails to scan.

Checked the other members against their Languages values (kotlin, golang, csharpsrc, php, abap):
Python was the only remaining gap.
Comment thread console/src/main/scala/io/joern/console/BridgeBase.scala Outdated
@max-leuthaeuser
max-leuthaeuser marked this pull request as ready for review September 6, 2026 14:42
@max-leuthaeuser
max-leuthaeuser merged commit 9ea1f8a into joernio:master Sep 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] joern-scan fails on Python projects: bundled script still calls importCode.pythonsrc instead of importCode.python

2 participants