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

refactor(repo): Simplify structure #308

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

refactor(repo): Simplify structure #308

wants to merge 7 commits into from

Conversation

simar7
Copy link
Member

@simar7 simar7 commented Jan 4, 2025

@simar7 simar7 force-pushed the refactor-structure branch from ad52a3f to e281ce0 Compare January 4, 2025 06:44
@simar7 simar7 requested a review from nikpivkin January 7, 2025 01:32
const ComplianceFolder = "compliance"
// Loader access compliance specs
type Loader interface {
GetSpecByName(name string) string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need for this interface?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not but since we already have it, removal of it would be a breaking change that I don't want to make in this PR.

go.mod Outdated Show resolved Hide resolved
@simar7 simar7 marked this pull request as ready for review January 15, 2025 05:15
@simar7
Copy link
Member Author

simar7 commented Jan 15, 2025

@itaysk for your review: do you want to keep node-collector commands in this repo? I don't think that feature was fully implemented and as a result there's most likely no consumer of this. I personally would move them out elsewhere as they're not checks per-se (maybe trivy-operator?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the project structure should be in the readme

@@ -7,10 +7,9 @@ This document aims to answer the question *Where is the code that does X?*
The directory structure is broken down as follows:

- `cmd/` - These CLI tools are primarily used during development for end-to-end testing without needing to pull the library into trivy/tfsec etc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could also be improved a bit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are any of the tools relevant for an external contributor? if so we should mention them

@@ -7,10 +7,9 @@ This document aims to answer the question *Where is the code that does X?*
The directory structure is broken down as follows:

- `cmd/` - These CLI tools are primarily used during development for end-to-end testing without needing to pull the library into trivy/tfsec etc.
- `checks` - All of the checks are defined in this directory.
- `checks` - All the checks are defined in this directory.
- `commands` - All Node-collector commands are defined in this directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's link to node collector docs to make sure the context is undestood

- `commands` - All Node-collector commands are defined in this directory.
- `pkg/spec` - Logic to handle standardized specs such as CIS.
- `pkg/rules` - This package exposes internal rules, and imports them accordingly (see _rules.go_).
- `pkg/rules` - This package exposes internal checks, and imports them accordingly (see _rules.go_).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this means. also 1. didn't we rename rules to checks? 2. shouldn't this code be in trivy?

- `commands` - All Node-collector commands are defined in this directory.
- `pkg/spec` - Logic to handle standardized specs such as CIS.
- `pkg/rules` - This package exposes internal rules, and imports them accordingly (see _rules.go_).
- `pkg/rules` - This package exposes internal checks, and imports them accordingly (see _rules.go_).
- `specs/` - Standaridized compliance specs such as CIS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think specs is oerloaded term. for a newcomer "specs" probably relate more to bdd specs or to standardidation specs. the feature in trivy is called "compliance" shouldn't the directory be called that way too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theres a doc about contributing compliance specs under docs/compliance.md. it's the only doc in the docs dir I thin we should make it a readme in this dir, like kubernetes related info is documented in readme under checks/kubernetes, then we can remove /docs, which should be in trivy anyway

| Target | Description |
|----------------|------------------------------------------------------------------------------------------------------------------------------------|
| Network | Checks primarily targeting the networking stack |
| Dynamic | Checks that evaluate deprecated and removed APIs |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either the description is not accurate or the dir name is bad. I think the intention was that these checks rely on environmental context for evaluation. for example, the deprecated API checks rely on information of which k8s version the user is running/evaluating against in order to decide if outdated or not.

|----------------|------------------------------------------------------------------------------------------------------------------------------------|
| Network | Checks primarily targeting the networking stack |
| Dynamic | Checks that evaluate deprecated and removed APIs |
| CIS Benchmarks | Checks that are recommended by the CIS Benchmarks. The checks inside are targeted per each subsystem (e.g. apiserver, cni, etc.) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this dir is serving only CIS, and CIS is using only this dir then fine, but I will challange us abit here: aren't these checks valid k8s checks also outside CIS context? aren't CIS reports include k8s checks besides these checks (i presume something like non privileged pod check).

| Network | Checks primarily targeting the networking stack |
| Dynamic | Checks that evaluate deprecated and removed APIs |
| CIS Benchmarks | Checks that are recommended by the CIS Benchmarks. The checks inside are targeted per each subsystem (e.g. apiserver, cni, etc.) |
| Advanced | Checks that are recommended for the advanced uesrs of Kubernetes |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we define advanced users

| CIS Benchmarks | Checks that are recommended by the CIS Benchmarks. The checks inside are targeted per each subsystem (e.g. apiserver, cni, etc.) |
| Advanced | Checks that are recommended for the advanced uesrs of Kubernetes |
| GKE | Checks specific to Google Kubernetes Engine |
| PSS | Checks pertaining to Pod Security Standards |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as CIS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be in trivy?

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.

3 participants