Skip to content
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

Revert base64 dependency upgrade #5647

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ path = "src/tests/all.rs"
anyhow = "=1.0.66"
aws-sigv4 = "=0.51.0"
axum = "=0.6.1"
base64 = "=0.20.0"
base64 = "=0.13.1"
cargo-registry-index = { path = "cargo-registry-index" }
cargo-registry-markdown = { path = "cargo-registry-markdown" }
cargo-registry-s3 = { path = "cargo-registry-s3" }
Expand Down
2 changes: 1 addition & 1 deletion cargo-registry-index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ testing = ["serde_json"]

[dependencies]
anyhow = "=1.0.66"
base64 = "=0.20.0"
base64 = "=0.13.1"
dotenv = "=0.15.0"
git2 = "=0.15.0"
serde = { version = "=1.0.150", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion cargo-registry-s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name = "s3"
path = "lib.rs"

[dependencies]
base64 = "=0.20.0"
base64 = "=0.13.1"
chrono = "=0.4.23"
sha-1 = "=0.10.1"
hmac = "=0.12.1"
Expand Down
12 changes: 4 additions & 8 deletions src/controllers/helpers/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use crate::util::errors::{bad_request, AppResult};
use crate::util::request_header;

use crate::App;
use base64::alphabet::URL_SAFE;
use base64::engine::fast_portable::{FastPortable, NO_PAD};
use diesel::pg::Pg;
use diesel::query_builder::*;
use diesel::query_dsl::LoadQuery;
Expand All @@ -22,8 +20,6 @@ const MAX_PAGE_BEFORE_SUSPECTED_BOT: u32 = 10;
const DEFAULT_PER_PAGE: u32 = 10;
const MAX_PER_PAGE: u32 = 100;

const URL_SAFE_NO_PAD: FastPortable = FastPortable::from(&URL_SAFE, NO_PAD);

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum Page {
Numeric(u32),
Expand Down Expand Up @@ -297,17 +293,17 @@ fn is_useragent_or_ip_blocked(config: &Server, req: &dyn RequestExt) -> bool {
/// technical measure to prevent API consumers for manually creating or modifying them, but
/// hopefully the base64 will be enough to convey that doing it is unsupported.
pub(crate) fn encode_seek<S: Serialize>(params: S) -> AppResult<String> {
Ok(base64::encode_engine(
Ok(base64::encode_config(
serde_json::to_vec(&params)?,
&URL_SAFE_NO_PAD,
base64::URL_SAFE_NO_PAD,
))
}

/// Decode a list of params previously encoded with [`encode_seek`].
pub(crate) fn decode_seek<D: for<'a> Deserialize<'a>>(seek: &str) -> AppResult<D> {
Ok(serde_json::from_slice(&base64::decode_engine(
Ok(serde_json::from_slice(&base64::decode_config(
seek,
&URL_SAFE_NO_PAD,
base64::URL_SAFE_NO_PAD,
)?)?)
}

Expand Down
6 changes: 1 addition & 5 deletions src/metrics/log_encoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use base64::alphabet::STANDARD;
use base64::engine::fast_portable::{FastPortable, PAD};
use base64::write::EncoderWriter;
use indexmap::IndexMap;
use prometheus::proto::{MetricFamily, MetricType};
Expand All @@ -13,8 +11,6 @@ use std::rc::Rc;

const CHUNKS_MAX_SIZE_BYTES: usize = 5000;

const BASE64_ENGINE: FastPortable = FastPortable::from(&STANDARD, PAD);

/// The `LogEncoder` struct encodes Prometheus metrics in the format [`crates-io-heroku-metrics`]
/// expects metrics to be logged. This can be used to forward instance metrics to it, allowing them
/// to be scraped by the Rust infrastructure monitoring system.
Expand Down Expand Up @@ -139,7 +135,7 @@ fn serialize_and_split_list<'a, S: Serialize + 'a>(
while items.peek().is_some() {
let mut writer = TrackedWriter::new();
let written_count = writer.written_count.clone();
let mut serializer = Serializer::new(EncoderWriter::from(&mut writer, &BASE64_ENGINE));
let mut serializer = Serializer::new(EncoderWriter::new(&mut writer, base64::STANDARD));

let mut seq = serializer.serialize_seq(None)?;
#[allow(clippy::while_let_on_iterator)]
Expand Down