Skip to content

Commit

Permalink
ci: upgrade oci conformance and print trow logs
Browse files Browse the repository at this point in the history
  • Loading branch information
awoimbee committed May 14, 2024
1 parent 8c87ce8 commit d0681b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ jobs:
id: start-container-image
run: |
docker load --input /tmp/trow_image.tar.zst
ID=$(docker run -d --name trow -p 8000:8000 trow:onpr)
ID=$(docker run -d -e RUST_LOG=debug --name trow -p 8000:8000 trow:onpr)
IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ID)
echo "container-ip=$IP" >> $GITHUB_OUTPUT
- name: Test connectivity
run: curl "http://${{ steps.start-container-image.outputs.container-ip }}:8000"
- name: Run OCI Distribution Spec conformance tests
uses: opencontainers/[email protected]-rc3
uses: opencontainers/[email protected]
env:
OCI_ROOT_URL: "http://${{ steps.start-container-image.outputs.container-ip }}:8000"
OCI_NAMESPACE: oci-conformance/distribution-test
Expand All @@ -96,6 +96,9 @@ jobs:
OCI_TEST_CONTENT_MANAGEMENT: 1
OCI_HIDE_SKIPPED_WORKFLOWS: 0
OCI_DEBUG: 0
- name: Print trow logs
if: always()
run: docker logs trow


helm-chart-validation:
Expand Down
20 changes: 4 additions & 16 deletions src/registry/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const BUFFER_SIZE: usize = 1024 * 1024;

// These regex are used to do a simple validation of the tag fields
lazy_static! {
static ref REGEX_ALGO: Regex = Regex::new(r"^[A-Za-z0-9_+.-]+$").unwrap();
static ref REGEX_DIGEST: Regex = Regex::new(r"^[A-Fa-f0-9]+$").unwrap();
static ref REGEX_DIGEST: Regex = Regex::new(r"^[A-Fa-f0-9]{32,}$").unwrap();
}

#[derive(Error, Debug)]
Expand Down Expand Up @@ -81,29 +80,18 @@ impl Digest {
.collect::<Vec<String>>();

// check that we have both parts: algo and digest
if algo_digest.len() < 2 {
if algo_digest.len() != 2 {
return Err(DigestError::InvalidDigest(format!(
"Component cannot be parsed into a digest: {}",
&digest_str
"Digest cannot be split into components: {digest_str}"
)));
}

// Do a simple verification
let algo = String::from(&algo_digest[0]);
let hash = String::from(&algo_digest[1]);

if !REGEX_ALGO.is_match(&algo) {
return Err(DigestError::InvalidDigest(format!(
"Component cannot be parsed into a TAG wrong digest algorithm: {} - {}",
&digest_str, &algo
)));
}

if !REGEX_DIGEST.is_match(&hash) {
return Err(DigestError::InvalidDigest(format!(
"Component cannot be parsed into a TAG wrong digest format: {} - {}",
&digest_str, &hash
)));
return Err(DigestError::InvalidDigest(format!("Invalid hash: {hash}")));
}

let algo_enum =
Expand Down

0 comments on commit d0681b0

Please sign in to comment.