-
Notifications
You must be signed in to change notification settings - Fork 43
PROJQUAY-11621: docs: add repo context files #163
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,127 @@ | ||||||||||||||||||||
| # container-security-operator Architecture | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Purpose | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Display Clair vulnerability scan results in OpenShift web console. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```mermaid | ||||||||||||||||||||
| flowchart LR | ||||||||||||||||||||
| quay[Quay and Clair] | ||||||||||||||||||||
| vuln[ImageManifestVuln CR] | ||||||||||||||||||||
| operator[container-security-operator] | ||||||||||||||||||||
| pods[Pods using scanned images] | ||||||||||||||||||||
| labels[security labels] | ||||||||||||||||||||
| console[OpenShift console] | ||||||||||||||||||||
|
|
||||||||||||||||||||
| quay --> vuln | ||||||||||||||||||||
| vuln --> operator | ||||||||||||||||||||
| pods --> operator | ||||||||||||||||||||
| operator --> labels | ||||||||||||||||||||
| labels --> pods | ||||||||||||||||||||
| pods --> console | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## High-Level Design | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``` | ||||||||||||||||||||
| Clair/Quay (creates ImageManifestVuln CRs) | ||||||||||||||||||||
| ↓ | ||||||||||||||||||||
| container-security-operator (watches CRs + Pods) | ||||||||||||||||||||
| ↓ Labels pods with vuln info | ||||||||||||||||||||
| OpenShift Console (displays security tab) | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Components | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### `/apis/secscan/v1alpha1` | ||||||||||||||||||||
| CRD definitions: | ||||||||||||||||||||
| - `ImageManifestVuln`: Vulnerability data for image manifest | ||||||||||||||||||||
| - Severity (Critical, High, Medium, Low) | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Incomplete severity enumeration in CRD definition. The - - Severity (Critical, High, Medium, Low)
+ - Severity (Defcon1, Critical, High, Medium, Low, Negligible, Unknown)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| - CVE details | ||||||||||||||||||||
| - Affected packages | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### `/cmd/manager` | ||||||||||||||||||||
| Operator entrypoint: | ||||||||||||||||||||
| - Controller manager | ||||||||||||||||||||
| - Watches ImageManifestVuln + Pod resources | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### `/labeller` | ||||||||||||||||||||
| Pod labeling logic: | ||||||||||||||||||||
| - Matches Pods to ImageManifestVuln by image digest | ||||||||||||||||||||
| - Adds labels: `secscan/hasVulnerabilities`, `secscan/highestSeverity` | ||||||||||||||||||||
| - Updates labels on vuln changes | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### `/k8sutils` | ||||||||||||||||||||
| Kubernetes client helpers: | ||||||||||||||||||||
| - Pod queries | ||||||||||||||||||||
| - Label updates | ||||||||||||||||||||
| - Event recording | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Data Flow | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``` | ||||||||||||||||||||
| 1. Quay/Clair scans image → creates ImageManifestVuln CR: | ||||||||||||||||||||
| apiVersion: secscan.quay.redhat.com/v1alpha1 | ||||||||||||||||||||
| kind: ImageManifestVuln | ||||||||||||||||||||
| metadata: | ||||||||||||||||||||
| name: sha256-abc123... | ||||||||||||||||||||
| spec: | ||||||||||||||||||||
| image: quay.io/org/app@sha256:abc123 | ||||||||||||||||||||
| manifest: sha256:abc123 | ||||||||||||||||||||
| features: | ||||||||||||||||||||
| - name: curl | ||||||||||||||||||||
| version: 7.68.0 | ||||||||||||||||||||
| vulnerabilities: | ||||||||||||||||||||
| - name: CVE-2023-1234 | ||||||||||||||||||||
| severity: High | ||||||||||||||||||||
| fixedBy: 7.68.1 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 2. operator watches ImageManifestVuln creation | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 3. operator queries Pods using image sha256:abc123 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 4. operator labels matching Pods: | ||||||||||||||||||||
| secscan/hasVulnerabilities: "true" | ||||||||||||||||||||
| secscan/highestSeverity: "High" | ||||||||||||||||||||
| secscan/affectedByVulns: "CVE-2023-1234,CVE-2023-5678" | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+84
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify affectedByVulns label existence and truncation logic
ast-grep run --pattern 'affectedByVulns' --lang go
rg -n 'affectedByVulns' --type=goRepository: quay/container-security-operator Length of output: 170 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== ARCHITECTURE.md around the cited lines ==\n'
sed -n '70,100p' ARCHITECTURE.md || true
printf '\n== Search for secscan label references ==\n'
rg -n 'secscan/|affectedByVulns|hasVulnerabilities|highestSeverity|CVE-2023|truncate|63 characters|label value limit' .
printf '\n== Go files mentioning secscan ==\n'
rg -n 'secscan' --type=go .Repository: quay/container-security-operator Length of output: 26996 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== labeller/manifest.go label construction ==\n'
sed -n '70,170p' labeller/manifest.go
printf '\n== label-related helpers in labeller/manifest.go ==\n'
sed -n '1,70p' labeller/manifest.go
printf '\n== occurrences of Label map keys in labeller ==\n'
rg -n 'Labels|labelPrefix|hasVulnerabilities|highestSeverity|affectedByVulns' labellerRepository: quay/container-security-operator Length of output: 6316 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== labeller/manifest.go 170-240 ==\n'
sed -n '170,240p' labeller/manifest.go
printf '\n== labeller/labeller.go label interactions ==\n'
sed -n '500,620p' labeller/labeller.go
printf '\n== search for Kubernetes label value length handling ==\n'
rg -n '63|length|truncate|truncat|label.*value|Kubernetes.*label|allowed by the label syntax' .Repository: quay/container-security-operator Length of output: 16486 Remove 🤖 Prompt for AI Agents |
||||||||||||||||||||
| 5. OpenShift console reads labels → displays in Security tab | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Labeling Strategy | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Pod labels: | ||||||||||||||||||||
| - `secscan/hasVulnerabilities`: "true" | "false" | ||||||||||||||||||||
| - `secscan/highestSeverity`: "Critical" | "High" | "Medium" | "Low" | ||||||||||||||||||||
| - `secscan/affectedByVulns`: comma-separated CVE list (truncated if >63 chars) | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+93
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Incomplete severity enumeration in label values. The - `secscan/highestSeverity`: "Critical" | "High" | "Medium" | "Low"
+ `secscan/highestSeverity`: "Defcon1" | "Critical" | "High" | "Medium" | "Low" | "Negligible" | "Unknown"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| ## Reconciliation | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``` | ||||||||||||||||||||
| Watch ImageManifestVuln: | ||||||||||||||||||||
| On create/update: | ||||||||||||||||||||
| - Extract image digest | ||||||||||||||||||||
| - Find Pods with matching image | ||||||||||||||||||||
| - Calculate highest severity | ||||||||||||||||||||
| - Apply labels | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Watch Pods: | ||||||||||||||||||||
| On create: | ||||||||||||||||||||
| - Extract image digest | ||||||||||||||||||||
| - Find ImageManifestVuln for digest | ||||||||||||||||||||
| - Apply labels if vulns exist | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Performance | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - Indexer for image digest → ImageManifestVuln mapping | ||||||||||||||||||||
| - Batch label updates (multiple pods with same image) | ||||||||||||||||||||
| - No polling (watch-based) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## OpenShift Integration | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Console plugin displays: | ||||||||||||||||||||
| - Vulnerability count by severity | ||||||||||||||||||||
| - CVE details with links to NVD | ||||||||||||||||||||
| - Affected packages + fixed versions | ||||||||||||||||||||
| - Drill-down from workload → vulns | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||||||
| # Contributing to container-security-operator | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Setup | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| # Requires OpenShift cluster with Quay integration | ||||||||||||||||||||||||||||||
| make install | ||||||||||||||||||||||||||||||
| make deploy | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Development | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Displays Clair vulnerability scan results in OpenShift console. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Watches: | ||||||||||||||||||||||||||||||
| - `ImageManifestVuln` CRs (created by Clair/Quay) | ||||||||||||||||||||||||||||||
| - Pods (to link vulns to running workloads) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Testing | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| # Unit tests | ||||||||||||||||||||||||||||||
| make test | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # E2E (requires OpenShift + Quay with Clair) | ||||||||||||||||||||||||||||||
| make test-e2e | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Pull Requests | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - Test on OpenShift 4.x | ||||||||||||||||||||||||||||||
| - Update labeller logic tests | ||||||||||||||||||||||||||||||
| - Verify console UI displays correctly | ||||||||||||||||||||||||||||||
| - Update CRD if adding new fields | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Code Structure | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - `apis/secscan/v1alpha1/` - CRD types | ||||||||||||||||||||||||||||||
| - `cmd/manager/` - operator entrypoint | ||||||||||||||||||||||||||||||
| - `labeller/` - pod vulnerability labeling | ||||||||||||||||||||||||||||||
| - `k8sutils/` - K8s client helpers | ||||||||||||||||||||||||||||||
| - `bundle/` - OLM metadata | ||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Directory path inconsistency and incompleteness. The Code Structure section lists - `apis/secscan/v1alpha1/` - CRD types
- - `cmd/manager/` - operator entrypoint
+ - `cmd/security-labeller/` - operator entrypoint
- `labeller/` - pod vulnerability labeling
- `k8sutils/` - K8s client helpers
+ - `secscan/` - registry client for vulnerability data
+ - `image/` - container image ID parsing
+ - `generated/` - auto-generated clients (do not edit)
+ - `hack/` - build scripts and helpers
- `bundle/` - OLM metadata📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -130,3 +130,26 @@ Check if a pod has any vulnerability, and list the CVEs, if any: | |||||
| ```sh | ||||||
| $ kubectl get imagemanifestvulns.secscan.quay.redhat.com --selector=<namespace>/<pod-name> -o jsonpath='{.items[*].spec.features[*].vulnerabilities[*].name}' | ||||||
| ``` | ||||||
|
|
||||||
| ## Contextification Addendum | ||||||
|
|
||||||
| ```mermaid | ||||||
| flowchart LR | ||||||
| quay[Quay and Clair] | ||||||
| vuln[ImageManifestVuln] | ||||||
| operator[container-security-operator] | ||||||
| pods[Pods] | ||||||
| labels[security labels] | ||||||
| console[OpenShift console] | ||||||
|
|
||||||
| quay --> vuln | ||||||
| vuln --> operator | ||||||
| pods --> operator | ||||||
| operator --> labels | ||||||
| labels --> pods | ||||||
| pods --> console | ||||||
| ``` | ||||||
|
|
||||||
| Key paths: `apis/secscan/v1alpha1/`, `cmd/`, `labeller/`, `secscan/`, `image/`, `generated/`, `bundle/`, and `hack/`. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use precise and consistent entrypoint directory name.
- Key paths: `apis/secscan/v1alpha1/`, `cmd/`, `labeller/`, `secscan/`, `image/`, `generated/`, `bundle/`, and `hack/`.
+ Key paths: `apis/secscan/v1alpha1/`, `cmd/security-labeller/`, `labeller/`, `secscan/`, `image/`, `generated/`, `bundle/`, and `hack/`.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| Use `make build`, `make run`, `make installcrds`, `go test -v ./...`, and `make codegen`. Do not edit generated clients manually. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify Makefile test target
cat Makefile | grep -A3 '^test:'Repository: quay/container-security-operator Length of output: 170 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'FILES:\n'
git ls-files | rg '(^|/)(Makefile|README\.md|CONTRIBUTING\.md)$' || true
printf '\nMAKEFILE TEST TARGET SEARCH:\n'
rg -n '^[[:space:]]*test:' Makefile || true
printf '\nMAKEFILE TEST REFERENCES:\n'
rg -n 'make test|go test -v ./\.\.\.|go test' Makefile README.md CONTRIBUTING.md || true
printf '\nCONTRIBUTING EXCERPT:\n'
if [ -f CONTRIBUTING.md ]; then
rg -n -A3 -B3 'make test|go test -v ./\.\.\.' CONTRIBUTING.md || true
fi
printf '\nREADME EXCERPT:\n'
if [ -f README.md ]; then
rg -n -A3 -B3 'make build|make run|make installcrds|go test -v ./\.\.\.|make codegen' README.md || true
fiRepository: quay/container-security-operator Length of output: 1229 🏁 Script executed: #!/bin/bash
set -euo pipefail
wc -l Makefile CONTRIBUTING.md README.md
printf '\nMAKEFILE TARGETS:\n'
rg -n '^[A-Za-z0-9_.-]+:' Makefile
printf '\nMAKEFILE TEST-RELATED LINES:\n'
rg -n 'go test|test-e2e|unit test|unit tests|test:' Makefile
printf '\nCONTRIBUTING TEST-RELATED LINES:\n'
rg -n -A2 -B2 'make test|go test|unit test|unit tests' CONTRIBUTING.md
printf '\nREADME TEST-RELATED LINES:\n'
rg -n -A2 -B2 'make test|go test|unit test|unit tests' README.mdRepository: quay/container-security-operator Length of output: 556 Standardize the test command in the docs
🤖 Prompt for AI Agents |
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Inconsistent entrypoint directory within the same file.
The low-token routing uses
cmd/but the Project Structure section above specifiescmd/security-labeller/. Use the precise path for consistency.📝 Committable suggestion
🤖 Prompt for AI Agents