forked from Deuxfleurs/garage
api: streaming signature: fix trailer parsing
This commit is contained in:
parent
21c0dda16a
commit
f8b0817ddc
2 changed files with 14 additions and 11 deletions
|
@ -11,7 +11,7 @@ PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:${NIX_RELEASE}:$PATH"
|
||||||
FANCYCOLORS=("41m" "42m" "44m" "45m" "100m" "104m")
|
FANCYCOLORS=("41m" "42m" "44m" "45m" "100m" "104m")
|
||||||
|
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
export RUST_LOG=garage=info,garage_api=debug
|
export RUST_LOG=garage=info,garage_api_common=debug,garage_api_s3=debug
|
||||||
MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m"
|
MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m"
|
||||||
|
|
||||||
if [ -z "$GARAGE_BIN" ]; then
|
if [ -z "$GARAGE_BIN" ]; then
|
||||||
|
|
|
@ -24,6 +24,11 @@ pub fn parse_streaming_body(
|
||||||
region: &str,
|
region: &str,
|
||||||
service: &str,
|
service: &str,
|
||||||
) -> Result<Request<ReqBody>, Error> {
|
) -> Result<Request<ReqBody>, Error> {
|
||||||
|
debug!(
|
||||||
|
"Content signature mode: {:?}",
|
||||||
|
checked_signature.content_sha256_header
|
||||||
|
);
|
||||||
|
|
||||||
let expected_checksums = ExpectedChecksums {
|
let expected_checksums = ExpectedChecksums {
|
||||||
sha256: match &checked_signature.content_sha256_header {
|
sha256: match &checked_signature.content_sha256_header {
|
||||||
ContentSha256Header::Sha256Checksum(sha256) => Some(*sha256),
|
ContentSha256Header::Sha256Checksum(sha256) => Some(*sha256),
|
||||||
|
@ -243,7 +248,7 @@ mod payload {
|
||||||
let (input, header_value) = try_parse!(take_while(
|
let (input, header_value) = try_parse!(take_while(
|
||||||
|c: u8| c.is_ascii_alphanumeric() || b"+/=".contains(&c)
|
|c: u8| c.is_ascii_alphanumeric() || b"+/=".contains(&c)
|
||||||
)(input));
|
)(input));
|
||||||
let (input, _) = try_parse!(tag(b"\n")(input));
|
let (input, _) = try_parse!(tag(b"\r\n")(input));
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
input,
|
input,
|
||||||
|
@ -257,15 +262,7 @@ mod payload {
|
||||||
pub fn parse_signed(input: &[u8]) -> nom::IResult<&[u8], Self, Error<&[u8]>> {
|
pub fn parse_signed(input: &[u8]) -> nom::IResult<&[u8], Self, Error<&[u8]>> {
|
||||||
let (input, trailer) = Self::parse_content(input)?;
|
let (input, trailer) = Self::parse_content(input)?;
|
||||||
|
|
||||||
let (input, _) = try_parse!(tag(b"\r\n\r\n")(input));
|
let (input, _) = try_parse!(tag(b"x-amz-trailer-signature:")(input));
|
||||||
|
|
||||||
Ok((input, trailer))
|
|
||||||
}
|
|
||||||
pub fn parse_unsigned(input: &[u8]) -> nom::IResult<&[u8], Self, Error<&[u8]>> {
|
|
||||||
let (input, trailer) = Self::parse_content(input)?;
|
|
||||||
|
|
||||||
let (input, _) = try_parse!(tag(b"\r\n")(input));
|
|
||||||
|
|
||||||
let (input, data) = try_parse!(map_res(hex_digit1, hex::decode)(input));
|
let (input, data) = try_parse!(map_res(hex_digit1, hex::decode)(input));
|
||||||
let signature = Hash::try_from(&data).ok_or(nom::Err::Failure(Error::BadSignature))?;
|
let signature = Hash::try_from(&data).ok_or(nom::Err::Failure(Error::BadSignature))?;
|
||||||
let (input, _) = try_parse!(tag(b"\r\n")(input));
|
let (input, _) = try_parse!(tag(b"\r\n")(input));
|
||||||
|
@ -278,6 +275,12 @@ mod payload {
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
pub fn parse_unsigned(input: &[u8]) -> nom::IResult<&[u8], Self, Error<&[u8]>> {
|
||||||
|
let (input, trailer) = Self::parse_content(input)?;
|
||||||
|
let (input, _) = try_parse!(tag(b"\r\n")(input));
|
||||||
|
|
||||||
|
Ok((input, trailer))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue