Repository navigation
Conversation
get_user()'s doc comment claimed `get_user(0)` was the equivalent of
MISP's "me" shortcut for the current user. MISP's
UsersController::view() only special-cases the literal string "me"
(app/Controller/UsersController.php:48-50, upstream-ref pin
843b67445060e4da71ebf75cc4a9646c301f749d):
if ("me" === $id) {
$id = $this->Auth->user('id');
}
`users/view/0` is not special-cased, falls through to the
User->find() lookup, and throws NotFoundException — the documented
shortcut was unreachable through an i64 parameter. PyMISP mirrors the
real API by accepting a string and defaulting to 'me'
(pymisp/api.py:2575-2583, pin e7debb4f0427dbc33800dc565d771ef1535f3c2f).
Add MispClient::get_user_me() (and the client_blocking wrapper) that
requests `users/view/me` directly, and drop the false claim from
get_user()'s doc comment. Added get_user_me_hits_literal_me_path,
which asserts the wiremock path is users/view/me.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoSButbVaWEtGMXwTx73BZ
elhoim
marked this pull request as draft
September 3, 2026 05:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BLUF — Add
get_user_me()for the current user and delete the false claim thatget_user(0)does it.UsersController::view()special-cases only the literal string"me";users/view/0is not special-cased and throwsNotFoundException, yetget_user()'s doc comment advertised it as the current-user shortcut.MispClient::get_user_me()to bothclient.rsandclient_blocking.rs, requestingusers/view/meas PyMISP'sget_user(user='me')default does, and removed the false line from the doc comment.ubuntu-22.04(no php8.3 mod_php) andtest_event_crud_lifecycleraced the publish worker; both fixed in PR fix: [ci] Run integration tests on ubuntu-24.04 to match php8.3 #53.Finding
doc says get_user(0) for current user but MISP special-cases the string "me"
users/view/0 throws NotFoundException; with an i64 parameter the real shortcut is unreachable.
Change
Confirmed the finding: MISP's UsersController::view() special-cases only the literal string "me" ($id = $this->Auth->user('id') when "me" === $id); users/view/0 is not special-cased and falls through to User->find(), throwing NotFoundException. The get_user() doc comment claiming get_user(0) reaches the current-user shortcut was false. Added MispClient::get_user_me() (async client.rs and blocking client_blocking.rs) that requests users/view/me directly, matching PyMISP's get_user(user='me') default, and removed the false claim from get_user()'s doc comment. Existing get_user_parses_wrapped test (asserts users/view/1) was already correct MISP truth and was left unchanged; added a new test for the new method.
Upstream evidence
MISP core app/Controller/UsersController.php:46-50 (
public function view($id = null) { if ("me" === $id) { $id = $this->Auth->user('id'); } ... }); PyMISP pymisp/api.py:2575-2583 (def get_user(self, user: ... = 'me', ...): user_id = get_uuid_or_id_from_abstract_misp(user); r = self._prepare_request('GET', f'users/view/{user_id}'))Verified against MISP core
843b6744and PyMISPe7debb4f.Tests
get_user_me_hits_literal_me_path (src/client.rs) - new wiremock test asserting GET users/view/me; fails before the fix via compile error since get_user_me() did not exist, passes after. The pre-existing get_user_parses_wrapped test asserts users/view/1 which is already correct MISP behavior and was left unchanged, not rewritten.Note on the original finding
Accurate as written. Verified against UsersController.php:48-50 that users/view/0 throws NotFoundException (no special case for 0) while "me" is the actual literal special-cased value, and that PyMISP (api.py:2575) defaults its user param to the string 'me'. The suggested fix (add get_user_me() and fix the doc) was the correct minimal remedy; no broader defect (e.g. in a shared request body) was found in this case.
Caveats
get_user_me_hits_literal_me_path fails before the fix because get_user_me() does not exist yet (compile error), not because an existing test encoded a wrong URL — there was no prior test covering the "me" path to correct. This is a low-severity, additive fix: get_user(i64) is unchanged in behavior aside from its corrected doc comment; get_user_me() is new API surface.
Verified locally:
cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings,cargo test --all-features --lib,--test integration_tests --no-run, andcargo check --examples, each in an isolated target directory.🤖 Generated with Claude Code