Skip to content

Commit

Permalink
chore: remove deny with sqlx
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Sep 25, 2024
1 parent 21f49f2 commit 9c8021d
Show file tree
Hide file tree
Showing 8 changed files with 445 additions and 257 deletions.
537 changes: 362 additions & 175 deletions Cargo.lock

Large diffs are not rendered by default.

92 changes: 41 additions & 51 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
# dependencies not shared by any other crates, would be ignored, as the target
# list here is effectively saying which targets you are building for.
targets = [
# The triple can be any string, but only the target triples built in to
# rustc (as of 1.40) can be checked against actual config expressions
#"x86_64-unknown-linux-musl",
# You can also specify which target_features you promise are enabled for a
# particular target. target_features are currently not validated against
# the actual valid features supported by the target architecture.
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
# The triple can be any string, but only the target triples built in to
# rustc (as of 1.40) can be checked against actual config expressions
#"x86_64-unknown-linux-musl",
# You can also specify which target_features you promise are enabled for a
# particular target. target_features are currently not validated against
# the actual valid features supported by the target architecture.
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] },
]
# When creating the dependency graph used as the source of truth when checks are
# executed, this field can be used to prune crates from the graph, removing them
Expand Down Expand Up @@ -70,23 +70,13 @@ feature-depth = 1
# A list of advisory IDs to ignore. Note that ignored advisories will still
# output a note when they are encountered.
ignore = [
# https://rustsec.org/advisories/RUSTSEC-2024-0363
# https://github.com/launchbadge/sqlx/issues/3440
# The queries for the rich indexer receive input parameters via RPC, and the data size is far less than 4GB, so this issue can be temporarily ignored while waiting for sqlx to be fixed.
"RUSTSEC-2024-0363",
# https://rustsec.org/advisories/RUSTSEC-2022-0090
# It was sometimes possible for SQLite versions >= 1.0.12, < 3.39.2 to allow an array-bounds overflow when large string were input into SQLite's `printf` function.
"RUSTSEC-2022-0090",
# https://rustsec.org/advisories/RUSTSEC-2024-0336
# `rustls::ConnectionCommon::complete_io` could fall into an infinite loop based on network input
"RUSTSEC-2024-0336",
# Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0370
# proc-macro-error's maintainer seems to be unreachable, with no commits for 2 years, no releases pushed for 4 years, and no activity on the GitLab repo or response to email.
"RUSTSEC-2024-0370"
#"RUSTSEC-0000-0000",
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
#"[email protected]", # you can also ignore yanked crate versions if you wish
#{ crate = "[email protected]", reason = "you can specify why you are ignoring the yanked crate" },
# Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0370
# proc-macro-error's maintainer seems to be unreachable, with no commits for 2 years, no releases pushed for 4 years, and no activity on the GitLab repo or response to email.
"RUSTSEC-2024-0370",
#"RUSTSEC-0000-0000",
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
#"[email protected]", # you can also ignore yanked crate versions if you wish
#{ crate = "[email protected]", reason = "you can specify why you are ignoring the yanked crate" },
]
# If this is true, then cargo deny will use the git executable to fetch advisory database.
# If this is false, then it uses a built-in git library.
Expand All @@ -102,16 +92,16 @@ ignore = [
# See https://spdx.org/licenses/ for list of possible licenses
# [possible values: any SPDX 3.11 short identifier (+ optional exception)].
allow = [
"MIT",
"Apache-2.0",
"MPL-2.0",
"BSL-1.0",
"BSD-3-Clause",
"ISC",
"CC0-1.0",
"Unicode-DFS-2016",
"OpenSSL"
#"Apache-2.0 WITH LLVM-exception",
"MIT",
"Apache-2.0",
"MPL-2.0",
"BSL-1.0",
"BSD-3-Clause",
"ISC",
"CC0-1.0",
"Unicode-DFS-2016",
"OpenSSL",
#"Apache-2.0 WITH LLVM-exception",
]
# The confidence threshold for detecting a license from license text.
# The higher the value, the more closely the license text must be to the
Expand All @@ -121,9 +111,9 @@ confidence-threshold = 0.8
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
# aren't accepted for every possible crate as with the normal allow list
exceptions = [
# Each entry is the crate and version constraint, and its specific allow
# list
# { allow = ["Zlib"], crate = "adler32" },
# Each entry is the crate and version constraint, and its specific allow
# list
# { allow = ["Zlib"], crate = "adler32" },
]

# Some crates don't have (easily) machine readable licensing information,
Expand All @@ -140,8 +130,8 @@ expression = "MIT AND ISC AND OpenSSL"
# and the crate will be checked normally, which may produce warnings or errors
# depending on the rest of your configuration
license-files = [
# Each entry is a crate relative path, and the (opaque) hash of its contents
{ path = "LICENSE", hash = 0xbd0eed23 }
# Each entry is a crate relative path, and the (opaque) hash of its contents
{ path = "LICENSE", hash = 0xbd0eed23 },
]

[licenses.private]
Expand All @@ -154,7 +144,7 @@ ignore = true
# is only published to private registries, and ignore is true, the crate will
# not have its license(s) checked
registries = [
#"https://sekretz.com/registry
#"https://sekretz.com/registry
]

# This section is considered when running `cargo deny check bans`.
Expand All @@ -181,16 +171,16 @@ workspace-default-features = "allow"
external-default-features = "allow"
# List of crates that are allowed. Use with care!
allow = [
#"[email protected]",
#{ crate = "[email protected]", reason = "you can specify a reason it is allowed" },
#"[email protected]",
#{ crate = "[email protected]", reason = "you can specify a reason it is allowed" },
]
# List of crates to deny
deny = [
#"[email protected]",
#{ crate = "[email protected]", reason = "you can specify a reason it is banned" },
# Wrapper crates can optionally be specified to allow the crate when it
# is a direct dependency of the otherwise banned crate
#{ crate = "[email protected]", wrappers = ["this-crate-directly-depends-on-ansi_term"] },
#"[email protected]",
#{ crate = "[email protected]", reason = "you can specify a reason it is banned" },
# Wrapper crates can optionally be specified to allow the crate when it
# is a direct dependency of the otherwise banned crate
#{ crate = "[email protected]", wrappers = ["this-crate-directly-depends-on-ansi_term"] },
]

# List of features to allow/deny
Expand Down Expand Up @@ -218,16 +208,16 @@ deny = [

# Certain crates/versions that will be skipped when doing duplicate detection.
skip = [
#"[email protected]",
#{ crate = "[email protected]", reason = "you can specify a reason why it can't be updated/removed" },
#"[email protected]",
#{ crate = "[email protected]", reason = "you can specify a reason why it can't be updated/removed" },
]
# Similarly to `skip` allows you to skip certain crates during duplicate
# detection. Unlike skip, it also includes the entire tree of transitive
# dependencies starting at the specified crate, up to a certain depth, which is
# by default infinite.
skip-tree = [
#"[email protected]", # will be skipped along with _all_ of its direct and transitive dependencies
#{ crate = "[email protected]", depth = 20 },
#"[email protected]", # will be skipped along with _all_ of its direct and transitive dependencies
#{ crate = "[email protected]", depth = 20 },
]

# This section is considered when running `cargo deny check sources`.
Expand Down
9 changes: 7 additions & 2 deletions util/rich-indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ log = "0.4"
num-bigint = "0.4"
once_cell = "1.8.0"
sql-builder = "3.1"
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "any", "sqlite", "postgres"] }
sqlx = { version = "0.8.2", features = [
"runtime-tokio-rustls",
"any",
"sqlite",
"postgres",
] }
include_dir = "0.7"
tempfile = "3"
tempfile.workspace = true

[dev-dependencies]
hex = "0.4"
Expand Down
14 changes: 7 additions & 7 deletions util/rich-indexer/src/indexer/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ pub(crate) async fn spend_cell(
)
.bind(output_tx_hash)
.bind(output_index as i32)
.execute(&mut *tx)
.execute(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?
.rows_affected();
Expand Down Expand Up @@ -458,7 +458,7 @@ pub(crate) async fn query_output_cell(
)
.bind(output_tx_hash)
.bind(output_index as i32)
.fetch_optional(tx)
.fetch_optional(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?;

Expand All @@ -484,7 +484,7 @@ pub(crate) async fn query_output_id(
)
.bind(output_tx_hash)
.bind(output_index as i32)
.fetch_optional(tx)
.fetch_optional(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))
.map(|row| row.map(|row| row.get::<i64, _>("id")))
Expand All @@ -508,7 +508,7 @@ pub(crate) async fn query_script_id(
.bind(code_hash)
.bind(hash_type)
.bind(args)
.fetch_optional(tx)
.fetch_optional(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))
.map(|row| row.map(|row| row.get::<i64, _>("id")))
Expand All @@ -528,7 +528,7 @@ pub(crate) async fn query_block_id(
"#,
)
.bind(block_hash)
.fetch_optional(tx)
.fetch_optional(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))
.map(|row| row.map(|row| row.get::<i64, _>("id")))
Expand Down Expand Up @@ -666,7 +666,7 @@ async fn bulk_insert(

// execute
query
.execute(&mut *tx)
.execute(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?;
}
Expand Down Expand Up @@ -695,7 +695,7 @@ async fn bulk_insert_and_return_ids(

// execute
let mut rows = query
.fetch_all(&mut *tx)
.fetch_all(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?;
id_list.append(&mut rows);
Expand Down
18 changes: 9 additions & 9 deletions util/rich-indexer/src/indexer/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async fn remove_batch_by_blobs(

// execute
query
.execute(tx)
.execute(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?;

Expand All @@ -98,7 +98,7 @@ async fn reset_spent_cells(tx_id_list: &[i64], tx: &mut Transaction<'_, Any>) ->
.map_err(|err| Error::DB(err.to_string()))?;

sqlx::query(&query)
.execute(&mut *tx)
.execute(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?;

Expand All @@ -117,7 +117,7 @@ async fn query_uncle_id_list_by_block_id(
"#,
)
.bind(block_id)
.fetch_all(tx)
.fetch_all(tx.as_mut())
.await
.map(|rows| rows.into_iter().map(|row| row.get("uncle_id")).collect())
.map_err(|err| Error::DB(err.to_string()))
Expand All @@ -131,7 +131,7 @@ async fn query_tip_id(tx: &mut Transaction<'_, Any>) -> Result<Option<i64>, Erro
LIMIT 1
"#,
)
.fetch_optional(tx)
.fetch_optional(tx.as_mut())
.await
.map(|res| res.map(|row| row.get::<i64, _>("id")))
.map_err(|err| Error::DB(err.to_string()))
Expand All @@ -150,7 +150,7 @@ async fn query_tx_id_list_by_block_id(
"#,
)
.bind(block_id)
.fetch_all(tx)
.fetch_all(tx.as_mut())
.await
.map(|rows| {
rows.into_iter()
Expand Down Expand Up @@ -185,7 +185,7 @@ async fn query_outputs_by_tx_id_list(

// execute
query
.fetch_all(&mut *tx)
.fetch_all(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))
.map(|rows| {
Expand Down Expand Up @@ -215,7 +215,7 @@ async fn script_exists_in_output(
"#,
)
.bind(script_id)
.fetch_one(&mut *tx)
.fetch_one(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?;

Expand All @@ -229,11 +229,11 @@ async fn script_exists_in_output(
"#,
)
.bind(script_id)
.fetch_one(&mut *tx)
.fetch_one(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?;

Ok(row_lock.get::<bool, _>(0) || row_type.get::<bool, _>(0))
Ok(row_lock.get::<i64, _>(0) == 1 || row_type.get::<i64, _>(0) == 1)
}

fn sqlx_param_placeholders(range: std::ops::Range<usize>) -> Result<Vec<String>, Error> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub async fn get_tx_with_cell(

// fetch
let outputs = query
.fetch_all(&mut *tx)
.fetch_all(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?
.iter()
Expand Down Expand Up @@ -399,7 +399,7 @@ pub async fn get_tx_with_cells(

// fetch
let outputs = query
.fetch_all(&mut *tx)
.fetch_all(tx.as_mut())
.await
.map_err(|err| Error::DB(err.to_string()))?
.iter()
Expand Down
Loading

0 comments on commit 9c8021d

Please sign in to comment.