-
Notifications
You must be signed in to change notification settings - Fork 1
fix(NATSRS-009): CU-86akbhh82 2 review findings in object_store.rs #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -365,13 +365,13 @@ impl ObjectStore { | |
| /// ``` | ||
| pub fn info(&self, object_name: &str) -> io::Result<ObjectInfo> { | ||
| // LoOkup the stream to get the bound subject. | ||
| let object_name = encode_object_name(object_name); | ||
| if !is_valid_object_name(&object_name) { | ||
| if !is_valid_object_name(object_name) { | ||
| return Err(io::Error::new( | ||
| io::ErrorKind::InvalidInput, | ||
| "invalid object name", | ||
| )); | ||
| } | ||
| let object_name = encode_object_name(object_name); | ||
|
|
||
| // Grab last meta value we have. | ||
| let stream_name = format!("OBJ_{}", &self.name); | ||
|
|
@@ -424,16 +424,16 @@ impl ObjectStore { | |
| ObjectMeta: From<T>, | ||
| { | ||
| let object_meta: ObjectMeta = meta.into(); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π put() also validates the base64-encoded name instead of the original object name In π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer |
||
| let object_name = encode_object_name(&object_meta.name); | ||
| if !is_valid_object_name(&object_name) { | ||
| if !is_valid_object_name(&object_meta.name) { | ||
| return Err(io::Error::new( | ||
| io::ErrorKind::InvalidInput, | ||
| "invalid object name", | ||
| )); | ||
| } | ||
| let object_name = encode_object_name(&object_meta.name); | ||
|
|
||
| // Fetch any existing object info, if there is any for later use. | ||
| let maybe_existing_object_info = match self.info(&object_name) { | ||
| let maybe_existing_object_info = match self.info(&object_meta.name) { | ||
| Ok(object_info) => Some(object_info), | ||
| Err(_) => None, | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π Regex compiled correctly via lazy_static, but is_valid_bucket_name double work with encode_object_name ordering bug
In
ObjectStore::info, reordered validation sois_valid_object_nameis called on the rawobject_nameparameter before it is shadowed/reassigned byencode_object_name(object_name). The base64 encoding now happens only after validation succeeds, so the regex validates caller-supplied input instead of the encoded string.π€ Prompt for AI agents
fix confidence: π‘ 85 medium β react π/π to teach the reviewer