Git Product home page Git Product logo

Comments (6)

danielpacak avatar danielpacak commented on June 14, 2024

/cc @knqyf263

from harbor-scanner-trivy.

msiebuhr avatar msiebuhr commented on June 14, 2024

Hacked it by looking for the IP in AWS' ip ranges (curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq | grep 52.216) and stuffing that into a Cilium policy:

  - description: "Allow Trivy to access vulnerability scans"
    endpointSelector:
      matchLabels:
        app: harbor
        component: trivy
    egress:
      - toFQDNs:
        - matchName: "api.github.com"
        toPorts:
          - ports:
            - port: "443"
              protocol: TCP

      # Found by watching cilium drop HTTPS to 52.216.160.91, realizing that's
      # an S3 address, getting AWS' S3-ranges and figuring which it came from
      # `curl https://ip-ranges.amazonaws.com/ip-ranges.json  | jq | grep
      # 52.216`
      - toCIDR:
        - '52.216.0.0/15'
        toPorts:
          - ports:
            - port: "443"
              protocol: TCP

from harbor-scanner-trivy.

knqyf263 avatar knqyf263 commented on June 14, 2024

@msiebuhr Thank you for sharing the behavior. I'm going to consider the message. As you said, GitHub Releases redirects to S3.

$ curl  https://github.com/aquasecurity/trivy-db/releases/download/v1-2020060912/trivy.db.gz
<html><body>You are being <a href="https://github-production-release-asset-2e65be.s3.amazonaws.com/216830441/7fffe500-aa4a-11ea-8fca-6d3aaa93a8ea?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200609%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20200609T144634Z&amp;X-Amz-Expires=300&amp;X-Amz-Signature=9febdfcab5cb5fe3edaae0a88b27a2f009488865610604fdff21dff4efe61bdd&amp;X-Amz-SignedHeaders=host&amp;actor_id=0&amp;repo_id=216830441&amp;response-content-disposition=attachment%3B%20filename%3Dtrivy.db.gz&amp;response-content-type=application%2Foctet-stream">redirected</a>.</body></html>% 

I'm not sure how flexible the egress rule is, but is it possible to allow s3.amazonaws.com and GET query? If so, you may be able to allow s3.amazonaws.com and filename=trivy.db.gz. I'm worried that the IP ranges will be changed.

from harbor-scanner-trivy.

msiebuhr avatar msiebuhr commented on June 14, 2024

Nice (I couldn't find the URL straight away, so I hacked up this other thing).

AFAIK, Cilium doesn't intercept HTTPS connections (I'd have to spoof AWS' TLS cert), so filename-inspection is off the table. Perhaps some wildcard'y stuff (github-production-release-asset-2e65be.s3.amazonaws.com feels like something that might change later on):

# Untested
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
  name: "fqdn"
spec:
  endpointSelector:
    matchLabels:
      app: harbor
      component: trivy
  egress:
  - toFQDNs:
    - matchPattern: "*.s3.amazonaws.com" 
   toPorts:
    - ports:
      - port: "443"
        protocol: TCP

from harbor-scanner-trivy.

knqyf263 avatar knqyf263 commented on June 14, 2024

I thought *.s3.amazonaws.com was a bit much since other buckets can be accepted. But if Cilium can't filter a request based on params, *.s3.amazonaws.com looks the best for now.

from harbor-scanner-trivy.

danielpacak avatar danielpacak commented on June 14, 2024

@msiebuhr are you okey to close this one? As @knqyf263 explained Trivy downloads a DB file from GitHub, which apparently redirects to S3. Beyond that, this adapter service just gets an error message from Trivy's output and returns back to display it the Harbor interface.

from harbor-scanner-trivy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.