Skip to content

Conversation

@harry-anderson
Copy link
Collaborator

@harry-anderson harry-anderson commented Nov 18, 2025

Improvements to the dynamodb api for rules:

@harry-anderson harry-anderson requested review from michelemin and obelisk and removed request for michelemin November 18, 2025 08:06
@harry-anderson harry-anderson marked this pull request as ready for review November 18, 2025 08:07
obelisk
obelisk previously approved these changes Nov 25, 2025
@obelisk
Copy link
Owner

obelisk commented Nov 25, 2025

@michelemin For one more review

Copy link
Collaborator

@michelemin michelemin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nits and typos

/// Configured readers - maps a table name to a list of rules that are allowed to READ data
r: HashMap<String, HashSet<String>>,
/// Reserved tables - list of 'reserved' table names which rules cannot access
/// For the purpose of preventing rules rule accessing 'storage' tables in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo - "preventing rules rule accessing"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think the entire second line should be removed. The first line seems sufficient.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/// Configured readers - maps a table name to a list of rules that are allowed to READ data
r: HashMap<String, HashSet<String>>,
/// Reserved tables - list of 'reserved' table names which rules cannot access
/// For the purpose of preventing rules rule accessing 'storage' tables in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


#[derive(PartialEq, PartialOrd)]
#[derive(PartialEq, PartialOrd, Debug)]
/// Represents an access scope for a rule has to modify a DynamoDB table
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
/// Represents an access scope for a rule has to modify a DynamoDB table
/// Represents an access scope that a rule has to modify a DynamoDB table

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 109 to 110
/// Checks if module can perform given give action
/// Modules are registerd as as read (R) or write (RW) under self.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typos

Suggested change
/// Checks if module can perform given give action
/// Modules are registerd as as read (R) or write (RW) under self.
/// Checks if module can perform a given action
/// Modules are registered as as read (R) or write (RW) under self.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +154 to +164
// check if read access is configured for this table
if let Some(table_readers) = self.r.get(table_name) {
// check if this module has read access to this table
if table_readers.contains(&module.to_string()) {
warn!(
"[{module}] trying to [write] but only has [read] permission for dynamodb table [{table_name}]"
);
return Err(ApiError::BadRequest);
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this block after checking for Write access.

Otherwise, imagine that a module appears both in the r and rw sections for a table: we would log a warning but then everything would be fine.

So I'd say we first check the happy path: if something goes wrong, we dig deeper and try to understand what happened.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants