Python extractor reports parse errors for files no longer in the scanned commit
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
Beginne damit, die Diagnosen des Python-Extractors gegen Commit 996e624 zu reproduzieren, bei dem die gemeldeten Dateien gelöscht wurden, und vergleiche die vom Extractor gescannte Dateimenge mit dem ausgecheckten Commit. Verwende python -m py_compile als Syntax-Baseline. Als erledigt gilt die Aufgabe, wenn akzeptierte Dateien keine falschen Parse-Fehler erzeugen und gelöschte Dateien nicht gemeldet werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Setup
- CodeQL version: 2.27.0
- Language: Python 3.13
- GitHub default CodeQL analysis (Advanced Security > Code scanning > Default setup)
- Repo (private): https://github.com/lumin-ai/lumin-bot
Observed behavior
CodeQL reports parse errors about two Python files. Here's a log sample (I've replaced my actual filenames with foo.py and bar.py):
Analysis produced the following diagnostic information:
##[group]Could not process some files due to syntax errors (2 results)
* foo.py#L0C0:0: A parse error occurred while processing `foo.py`, and as a result this file could not be analyzed. Check the syntax of the file using the `python -m py_compile` command and correct any invalid syntax.
* bar.py#L0C0:0: A parse error occurred while processing `bar.py`, and as a result this file could not be analyzed. Check the syntax of the file using the `python -m py_compile` command and correct any invalid syntax.
##[endgroup]
What I tried
-
I ran
python -m py_compileon both files. This check completed without errors on Python 3.7, 3.8, 3.9, 3.10, 3.11, and 3.12. -
I removed an old header from the files:
# -*- coding: future_fstrings -*-. This header was a leftover from a Python 2 to Python 3 migration involving https://github.com/asottile-archive/future-fstrings. The warnings stayed. (I imagine, but am not sure, that this header caused the original parsing problem. These two files were the only ones in the repo that still had it.) -
I checked the files for invisible characters and for a byte order mark. The only non-ASCII characters were some bullet characters inside one docstring. I replaced them with ASCII hyphens. The warnings stayed.
-
I replaced the full contents of both files with a single
passstatement. The warnings stayed. -
I deleted both files. The warnings stayed. I believe these logs confirm that CodeQL scanned the commit where I deleted the files (commit 996e624 in pull request 3584):
##[group]Checking out the ref [command]/usr/bin/git checkout --progress --force refs/remotes/pull/3584/head Note: switching to 'refs/remotes/pull/3584/head'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c <new-branch-name> Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at 996e624 bisect: blow away the whole python modules to see if codeql still complains [skip tests] ##[endgroup]
Expected behavior
- CodeQL must not report parse errors for Python files that
python -m py_compileaccepts. - CodeQL must not report parse errors for files that do not exist in the scanned commit.
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.1k
- Forks
- 2.1k
- Ø Merge
- 2 T. 10 Std.
- Gemergte PRs (30 T.)
- 134
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/codeql
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
false-positive
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
false-positive
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
ScoopInstaller/Nonportable#639 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
ScoopInstaller/Extras#18800 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
uqbar-project/website-wollok-ts#84 · 2 Kommentare ·
-
on hold T: core-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100