Conversation
|
Caution Review failedPull request was closed or merged during review WalkthroughIntroduces a JSON “validator wrapper” config ( Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@geyser-plugin/Makefile`:
- Around line 21-25: The init-config perl replacements are turning an existing
"../target/release/..." path into "../../target/..." because the regex blindly
matches "target/release/..." even when already prefixed; update the two perl
substitution expressions so they only replace bare "target/release/..."
occurrences that are not already prefixed (e.g., use a negative lookbehind like
(?<!\.\./) or a start-of-string/quote-aware anchor) and apply the fix to both
commands that produce $(PLUGIN_CONFIG) and $(VALIDATOR_CONFIG), ensuring
PLUGIN_PATH is inserted only once.
- Around line 40-44: The preflight check currently fails if $(PLUGIN_CONFIG) is
missing; change it to allow valid JSON wrappers by also honoring the runtime
config path stored as config_file inside $(VALIDATOR_CONFIG): update the
Makefile check so it passes when either $(PLUGIN_CONFIG) exists OR
$(VALIDATOR_CONFIG) contains a non-empty config_file value (pointing to an
absolute or differently named TOML path); implement this by parsing
$(VALIDATOR_CONFIG) for the config_file key and using that path as an acceptable
plugin config source (while still erroring if neither condition is met).
In `@geyser-plugin/src/config.rs`:
- Around line 131-138: The code currently swallows serde_json::from_str errors
and falls back to TOML, hiding JSON wrapper parse issues; update the logic
around the serde_json::from_str::<ValidatorConfig>(&contents) call (and the
runtime_path determination using resolve_runtime_config_path and variable
runtime_path) so that if parsing fails and the source is a JSON file
(config_path extension == "json") or the contents look like JSON (trimmed
starts_with('{') or '['), you propagate/return the JSON parse error instead of
falling back to config_path.to_path_buf(); otherwise (non-JSON file/contents)
continue with the existing TOML fallback behavior. Ensure you use the original
serde_json error (not a generic Err(_)) so the caller sees the real parsing
failure.
In `@geyser-plugin/src/ksql.rs`:
- Line 35: The SQL string interpolation uses self.table unescaped (let sql =
format!("SELECT PUBKEY FROM {};", self.table)), so add validation or safe
quoting before formatting: implement a helper like
validate_ksql_identifier(identifier: &str) -> io::Result<&str> that ensures the
identifier starts with a letter or '_' and contains only ASCII alphanumeric or
'_' (or alternatively implement proper double-quoting with escaping), call that
helper on self.table in the function that builds sql (the place where sql is
defined) and return an Err if validation fails; then use the validated/quoted
value when constructing the SELECT statement to prevent injection/invalid
identifiers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: efd80f80-c78d-442c-8c8a-34ec6ea95088
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
geyser-plugin/Cargo.tomlgeyser-plugin/Makefilegeyser-plugin/README.mdgeyser-plugin/configs/plugin-config.example.jsongeyser-plugin/configs/plugin-config.example.tomlgeyser-plugin/plugin-config.tomlgeyser-plugin/src/account_update_publisher.rsgeyser-plugin/src/config.rsgeyser-plugin/src/ksql.rs
💤 Files with no reviewable changes (2)
- geyser-plugin/plugin-config.toml
- geyser-plugin/configs/plugin-config.example.toml
Amp-Thread-ID: https://ampcode.com/threads/T-019dce32-32f7-7779-af5a-cf80c3f4b9b2 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dce34-6384-7068-938f-012ea8571e67 Co-authored-by: Amp <amp@ampcode.com>
When read_from receives a JSON-looking input (extension is .json or
contents start with { or [), surface the original serde_json parse
error instead of silently falling back to TOML parsing, which would
produce a misleading TOML error for a malformed validator wrapper.
Amp-Thread-ID: https://ampcode.com/threads/T-019dce36-f46e-762c-b867-c6a2743093b0
Co-authored-by: Amp <amp@ampcode.com>
The fetch_pubkeys query previously interpolated self.table directly into the SELECT statement, which would allow SQL injection or invalid identifiers if the configured table name contained unexpected characters. Add a validate_ksql_identifier helper that requires the identifier to start with an ASCII letter or '_' and contain only ASCII alphanumeric characters or '_', call it before formatting the query, and return an io::Error on failure. Also adds tests covering the validator's accept and reject paths. Amp-Thread-ID: https://ampcode.com/threads/T-019dce38-5a38-770a-8f3b-a0773875c151 Co-authored-by: Amp <amp@ampcode.com>
Summary
Split the geyser plugin startup config into a validator-facing JSON wrapper and a plugin runtime TOML config so
solana-test-validatorcan keep loading the plugin through its expected JSON entrypoint while the plugin itself uses TOML for runtime settings.Also fixed the startup path around ksql restore and Agave version alignment by pinning the plugin to the validator's
4.0.0-beta.4crates, correcting the generated shared-library path used by local launch targets, and handling ksql startup restore queries and HTTP errors more defensively.Details
Config loading and launch flow
libpathplus the TOML runtime config pathlibpathfrom the TOML runtime config and updated local examples, docs, and Makefile targets to generate and use the two-file setuptarget/releaseartifact correctlyValidator and ksql startup fixes
4.0.0-beta.4line as the installed validator to avoid runtime mismatch during plugin loadNoise reduction
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores