-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Slack us first!
Done!
Be informative
Regarding the logs of the uwsgi container, it correctly shows the username of the user making the request on the web server, but doesn't for the API calls.
When using the web interface (to access web pages), the uwsgi container logs the following:
uwsgi-1 | [pid: 41|app: -|req: -/-] 172.18.0.1 (USERNAME) {64 vars in 1258 bytes} [XXX] GET /alerts/count => generated 15 bytes in 57 msecs (HTTP/1.1 200) 7 headers in 212 bytes (1 switches on core 1)
However, when making a request to the API using an API token, the log is as follow:
uwsgi-1 | [pid: 41|app: -|req: -/-] 172.18.0.1 (-) {44 vars in 681 bytes} [XXX] GET /api/v2/findings/3473444/ => generated 2403 bytes in 311 msecs (HTTP/1.1 200) 8 headers in 261 bytes (1 switches on core 2)
Notice the dash instead of the username of the user who generated the API token and performed the request.
This appears only when using the Token provided by the /api/key-v2 page.
If the user uses the swagger UI to make the API request, then the username correctly appears.
After discussion on Slack:
So issue is connected to AuthN method, not to url.
This may need custom middleware to get loggeed: https://stackoverflow.com/questions/26240832/django-and-middleware-which-uses-request-user-is-always-anonymous
Bug description
A clear and concise description of what the bug is. For errors include at least the exact error message you are seeing (including traceback).
Steps to reproduce
Steps to reproduce the behavior:
- Go to
/api/key-v2page using web interface - Copy the given python code example (using Authorization Token in the headers)
- Execute the script
- Look at the uwsgi container logs and notice that the username doesn't appear in the logged request
Expected behavior
I expect the username to appear in the logs.
The logs are used for traceability and having no indication of the user that performed a request is a flaw that prevent forensic analysis or event simply traceability.
Deployment method
- Docker Compose
- Kubernetes
- GoDojo
Environment information
- Operating System: Debian 12
- Docker Compose: v2.39.4
- DefectDojo version: tested on v2.51.3 and v2.52.1
Logs
uwsgi-1 | [pid: 41|app: -|req: -/-] 172.18.0.1 (USERNAME) {64 vars in 1258 bytes} [XXX] GET /alerts/count => generated 15 bytes in 57 msecs (HTTP/1.1 200) 7 headers in 212 bytes (1 switches on core 1)
uwsgi-1 | [pid: 41|app: -|req: -/-] 172.18.0.1 (-) {44 vars in 681 bytes} [XXX] GET /api/v2/findings/3473444/ => generated 2403 bytes in 311 msecs (HTTP/1.1 200) 8 headers in 261 bytes (1 switches on core 2)
Sample scan files
N/A
Screenshots
N/A
Additional context (optional)
N/A