-
Notifications
You must be signed in to change notification settings - Fork 44
Add a function to list all the allowlisted crates with their respecti… #373
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
Conversation
…ve versions and features
|
Thanks! I’ll provide some feedback in the morning. |
workingjubilee
left a comment
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.
Some nits.
| Box<dyn std::error::Error + Send + Sync + 'static>, | ||
| > { | ||
| let allowed_dependencies = allow_list::get_allowed_dependencies_as_tuple_vector(); | ||
| Ok(Some(TableIterator::new(allowed_dependencies))) | ||
| } |
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.
The only unfortunate thing is I don't think there's an easy way yet to simply yield a TableIterator that yields the equivalent of a Rust struct so I guess this would have to .map() the struct back down to a tuple anyway... hmm... annoying... I should fix that. I mean, PL/Rust users aren't exposed to how grody it is, but
| let name = dep.name.clone(); | ||
| let ver = version | ||
| .get("version") | ||
| .unwrap() |
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.
If it's possible for the "version" to be None, then we should account for that here and in our data structure instead of panicking.
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.
version can be None, but i think load_allowlist is already checking if version is set for an allowed dependency
(23-08-17 12:55:17) [~/pg_data]
$ > cat ~/allow.toml
foo = { features = ["bar"] }
(23-08-17 12:55:58) [~/pg_data]
$ > psql -d postgres -c 'SELECT * FROM plrust.allowed_dependencies();'
ERROR: Error loading dependency allow-list:
0: Dependency entry is missing the `version` attribute
Location:
plrust/src/allow_list.rs:432
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
it also validates the Value is a string
(23-08-17 12:57:51) [~/pg_data]
$ > cat ~/allow.toml
foo = { version = ["1.0"], features = ["bar"] }
(23-08-17 12:57:56) [~/pg_data]
$ > psql -d postgres -c 'SELECT * FROM plrust.allowed_dependencies();'
ERROR: Error loading dependency allow-list:
0: Unsupported value type: Array([String("1.0")])
Location:
plrust/src/allow_list.rs:432
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
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.
Yeah, I think we're fine here. A dependency is only coherent with a version of some sort, since a Rust dependency, as far as cargo is concerned, is not a crate name but also its version, so panicking is okay.
…ve versions and features
Add new line at the bottom of control file
| let name = dep.name.clone(); | ||
| let ver = version | ||
| .get("version") | ||
| .unwrap() |
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.
Yeah, I think we're fine here. A dependency is only coherent with a version of some sort, since a Rust dependency, as far as cargo is concerned, is not a crate name but also its version, so panicking is okay.
workingjubilee
left a comment
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.
Apologies, Eric's remarks highlighted some things I missed on my first scan.
…n toml file; Update doc for using the plrust.allowed_dependencies function
workingjubilee
left a comment
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.
This looks good to me, thank you!
This commit addresses issue #371
Introduce a function to list all the allowed dependencies and their respective versions and features.
E.g Given a toml like this,
the function returns a table
This commit also bumps plrust to 1.1 and introduce the sql script for schema upgrade
Testing