Repository navigation
Conversation
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no significant new problems in the new tools/donate-cpu-server-rest.py. The parsing, the reports and the path checks match what donate-cpu-server.py does as far as I could check.
The one new issue is minor and I checked it by reasoning, not by running the server. On the name detail pages (/check_library-…, /unknown_macro-…, /incomplete_var-…), the "packages.txt" link comes from request.url.path, which is already percent-decoded. The handler then decodes the path again with unquote_plus. For a name that contains a literal +, the link therefore asks for a different name and the list comes back empty.
The PR changes no C/C++ code, and the two CodeQL threads are from a bot, so they get no entries.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | packages.txt link on name pages is decoded twice, so names containing '+' break | AI review | tools/donate-cpu-server-rest.py:967 |
🆕 New |
@danmar, please fix, resolve or reply to the open and new comments: #1.
Testing
- The PR only adds a Python tool, its test and a CI step, so I did not build
cppcheckortestrunner. - The server and its tests could not be run.
fastapi,uvicorn,jinja2andhttpxare not installed in the container, and with no network and nopipthey could not be installed. The newtest/tools/donate_cpu_server_rest_test.pywould be skipped throughimportorskip. - I put stub
fastapi,jinja2,uvicornandpydanticmodules inscratch/stubsso that I could import the module and call the pure functions directly (parse_result,parse_info,safe_path, …).- The parser gives the expected results for the header, head and diff sections and for crash stack traces.
- The crash parser drops the first non-frame line after a stack trace when there is no blank line before it (it reported
syntaxError: 1for two warnings). Real clients only send gdb output for a crash, so this does not seem to matter in practice and I did not report it.
- Both new files parse with Python 3.7 grammar (
ast.parse(..., feature_version=(3,7))). That matters because CI runspy_compileon 3.7 as well. - The
+problem in the packages.txt link, reproduced by simulating the URL handling:
python3 -c "
import urllib.parse as u
name='operator+()'
href="https://github.com/check_library-"+u.quote_plus(name); print('link', href)
decoded=u.unquote(href) # what scope['path'] / request.url.path holds
print('pkgs link', decoded+'?pkgs=1')
print('name parsed from pkgs link', repr(u.unquote_plus(decoded[len('/check_library-'):])))"
link /check_library-operator%2B%28%29
pkgs link /check_library-operator+()?pkgs=1
name parsed from pkgs link 'operator ()'
Automated review of 080b56e by Claude. The pull request was built and tested locally.
| def with_query(request: Request, **params: str) -> str: | ||
| query = dict(request.query_params) | ||
| query.update(params) | ||
| return request.url.path + '?' + urllib.parse.urlencode(query) |
There was a problem hiding this comment.
AI review
request.url.path is built from the percent-decoded scope['path']. On the name detail pages (/check_library-…, /unknown_macro-…, /incomplete_var-…) this link is then decoded a second time by _raw_suffix(), which uses unquote_plus.
For a name that contains a literal +, the report links to /check_library-operator%2B%28%29. The "packages.txt" link built here becomes /check_library-operator+()?pkgs=1, which is read back as the name operator (), so the list is empty.
Fix: build the link from the raw path (request.scope['raw_path']) or quote the path again, for example urllib.parse.quote(request.url.path), keeping + encoded as %2B.
No description provided.