diff --git a/.github/workflows/pr-tests.yaml b/.github/workflows/pr-tests.yaml index d90232da..8b0248e4 100644 --- a/.github/workflows/pr-tests.yaml +++ b/.github/workflows/pr-tests.yaml @@ -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/distribution-spec@v1.1.0-rc3 + uses: opencontainers/distribution-spec@v1.1.0 env: OCI_ROOT_URL: "http://${{ steps.start-container-image.outputs.container-ip }}:8000" OCI_NAMESPACE: oci-conformance/distribution-test @@ -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: diff --git a/src/registry/digest.rs b/src/registry/digest.rs index 6cb91358..53dd1b86 100644 --- a/src/registry/digest.rs +++ b/src/registry/digest.rs @@ -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)] @@ -81,10 +80,9 @@ impl Digest { .collect::>(); // 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}" ))); } @@ -92,18 +90,8 @@ impl Digest { 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 =