Skip to content
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

Enhance artifact pull and push commands #112

Merged
merged 15 commits into from
Jun 21, 2024
Merged

Enhance artifact pull and push commands #112

merged 15 commits into from
Jun 21, 2024

Conversation

santoshkal
Copy link
Collaborator

@santoshkal santoshkal commented Jun 19, 2024

This PR enhances artifact pull and push commands by implementing an incremental retry in case of failures while pulling and pushing artifacts. Additionally, references to OCI registries must now be prefixed with oci:// to differentiate between HTTP and OCI operations.
Moreover, users can provide rego policies packaged and stored in an OCI-compatible registry.
Dockerfile policies from OCI registry:

rego-oci

Infrafile policies from registries:

infra-oci

Generating Dockerfiles and validating with policies stored in OCI registries:

gen-oci

Closes: #96 #103

…oci://' prefix

- Users can now pass Registry Tokens as credential while using pull/push commands.
- OCI URLs need to provided prefixed with 'oci://' to differenciate between HTTP and OCI operations.
- Implementation of exponential retry logic while pulling and pushing from registries.
- Update OCI urls for pulling deault policies for Rego validation.
Signed-off-by: Santosh <ksantosh@intelops.dev>
Signed-off-by: Santosh <ksantosh@intelops.dev>
…tries

Signed-off-by: Santosh <ksantosh@intelops.dev>
Signed-off-by: santoshkal <ksantosh@intelops.dev>
Signed-off-by: santoshkal <ksantosh@intelops.dev>
Copy link

dryrunsecurity bot commented Jun 19, 2024

Hi there 👋, @DryRunSecurity here, below is a summary of our analysis and findings.

DryRun Security Status Findings
Server-Side Request Forgery Analyzer 0 findings
Configured Codepaths Analyzer 0 findings
IDOR Analyzer 0 findings
SQL Injection Analyzer 0 findings
Secrets Analyzer 0 findings
Authn/Authz Analyzer 34 findings
Sensitive Files Analyzer 2 findings

Note

🟢 Risk threshold not exceeded.

Change Summary (click to expand)

The following is a summary of changes in this pull request made by me, your security buddy 🤖. Note that this summary is auto-generated and not meant to be a definitive list of security issues but rather a helpful summary from a security perspective.

Summary:

The changes in this pull request focus on enhancing the security and functionality of the Genval application, a configuration management tool for generating and validating Infrastructure as Code (IaC) files. The key improvements include:

  1. Improved OCI Registry Integration: The application now supports fetching security policies from OCI-compliant container registries, allowing for centralized management and distribution of security policies. This includes the ability to provide credentials for accessing the registries, improving the overall security of the policy retrieval process.

  2. Enhanced Artifact Handling: The changes introduce improvements to the artifact pulling and pushing functionality, including support for signature verification using Cosign and better error handling. These enhancements help ensure the integrity and authenticity of the generated artifacts.

  3. Expanded Validation Capabilities: The application now supports validating a wider range of file types, including Dockerfiles, Kubernetes manifests, CRD manifests, and Terraform files, against both local and OCI-based security policies. This improves the overall security posture of the generated configurations.

  4. Improved Usability and Documentation: The changes include updates to the command-line interface, shell completion functionality, and the project's README, making the application more user-friendly and providing better guidance for users.

Overall, these changes demonstrate a strong focus on improving the security and reliability of the Genval application, which is crucial for managing the security of infrastructure-as-code deployments.

Files Changed:

  1. README.md: Updated to provide more information about the Genval tool, including details on policy validation, Cue lang support, and artifact management.
  2. .goreleaser.yaml: Introduced changes to the changelog configuration and added artifact signing using Cosign.
  3. .gitignore: Updated to ignore new files and directories related to the project.
  4. cmd/artifact_pull.go: Improved authentication and signature verification for artifact pulling.
  5. cmd/completion.go: Added a new command for generating shell completion scripts.
  6. cmd/cuemod_init.go: Enhanced the workspace initialization process, including artifact verification and credential management.
  7. cmd/artifact_push.go: Improved the artifact pushing functionality, including support for Cosign signing.
  8. cmd/container.go: Expanded the Dockerfile validation capabilities, including support for OCI-based policies.
  9. cmd/cue.go: Updated the command-line flag for the "cue" command.
  10. cmd/root.go: Improved the documentation and usability of the root command.
  11. cmd/regoval_dockerfileval.go: Added support for fetching Rego policies from OCI registries.
  12. cmd/regoval_infrafile.go: Enhanced the Kubernetes manifest validation capabilities using OCI-based policies.
  13. go.mod: Added a new dependency, gotest.tools/v3 v3.5.1.
  14. pkg/oci/constants.go: Updated the policy URLs and the FetchPolicyFromRegistry function.
  15. cmd/regoval_terraform.go: Added support for validating Terraform configurations against OCI-based policies.
  16. pkg/oci/ociUtils.go: Introduced a new function, ParseOCIReference, to handle OCI URL parsing.
  17. pkg/oci/ociClient.go: Improved the credential handling and retry mechanism for artifact pulling.
  18. pkg/validate/constants.go: Added a new constant for a Rego policy image location.
  19. pkg/validate/regoval.go: Enhanced the OCI policy handling and input validation process.

Powered by DryRun Security

Signed-off-by: santoshkal <ksantosh@intelops.dev>
@santoshkal santoshkal changed the title Enhance artifact pull and [ush commands Enhance artifact pull and push commands Jun 19, 2024
Signed-off-by: santoshkal <ksantosh@intelops.dev>
…istries for dockerfile command

Signed-off-by: santoshkal <ksantosh@intelops.dev>
…olicies from OCI registries for all Rego commands

Signed-off-by: santoshkal <ksantosh@intelops.dev>
- Move out auth related logic to its own GetCreds().
- Now, users can pass creds through --credentials flag
- accepts auth in <$USER:$PAT> or <$TOKEN> format
- If none provided falls back to /home/santosh/.docker/config.json
- Updated examples for all commands for using default policies and policies from OCI registries

Signed-off-by: santoshkal <ksantosh@intelops.dev>
…v file

This behaviour is for testing the commands and would be updated to read the URLs for all commands from a .env file
stored in a repo

Signed-off-by: santoshkal <ksantosh@intelops.dev>
…rregistry

Signed-off-by: santoshkal <ksantosh@intelops.dev>
… and policies from OCI registries

Signed-off-by: santoshkal <ksantosh@intelops.dev>
Signed-off-by: santoshkal <ksantosh@intelops.dev>
Signed-off-by: santoshkal <ksantosh@intelops.dev>
@santoshkal santoshkal merged commit dd7f5e3 into main Jun 21, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance the Push and Pull commands with refined auth and Retry logic
2 participants