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

Add support for Inspektor Gadgets #3693

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ At the moment, the following artifacts kinds are supported *(with plans to suppo
- [Headlamp plugins](https://headlamp.dev)
- [Helm charts](https://helm.sh/)
- [Helm plugins](https://helm.sh/docs/topics/plugins/)
- [Inspektor Gadgets](https://www.inspektor-gadget.io)
- [KCL modules](https://kcl-lang.io)
- [KEDA scalers](https://keda.sh/)
- [Keptn integrations](https://keptn.sh)
Expand Down
3 changes: 2 additions & 1 deletion charts/artifact-hub/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: artifact-hub
description: Artifact Hub is a web-based application that enables finding, installing, and publishing Kubernetes packages.
type: application
version: 1.17.0
version: 1.17.1-0
appVersion: 1.17.0
kubeVersion: ">= 1.19.0-0"
home: https://artifacthub.io
Expand All @@ -29,6 +29,7 @@ keywords:
- kubearmor
- kcl
- headlamp
- inspektor gadget
maintainers:
- name: Sergio
email: [email protected]
Expand Down
2 changes: 1 addition & 1 deletion charts/artifact-hub/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@
},
"repositoriesKinds": {
"title": "Repositories kinds to process ([] = all)",
"description": "The following kinds are supported at the moment: falco, helm, olm, opa, tbaction, krew, helm-plugin, tekton-task, keda-scaler, coredns, keptn, tekton-pipeline, container, kubewarden, gatekeeper, kyverno, knative-client-plugin, backstage, argo-template, kubearmor, kcl, headlamp",
"description": "The following kinds are supported at the moment: falco, helm, olm, opa, tbaction, krew, helm-plugin, tekton-task, keda-scaler, coredns, keptn, tekton-pipeline, container, kubewarden, gatekeeper, kyverno, knative-client-plugin, backstage, argo-template, kubearmor, kcl, headlamp, inspektor-gadget",
"type": "array",
"items": {
"type": "string"
Expand Down
4 changes: 3 additions & 1 deletion cmd/ah/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func newLintCmd() *cobra.Command {
return lint(opts, &output{cmd.OutOrStdout()})
},
}
lintCmd.Flags().StringVarP(&opts.kind, "kind", "k", "helm", "repository kind: argo-template, backstage, coredns, falco, gatekeeper, headlamp, helm, helm-plugin, kcl, keda-scaler, keptn, knative-client-plugin, krew, kubearmor, kubewarden, kyverno, olm, opa, tbaction, tekton-task, tekton-pipeline")
lintCmd.Flags().StringVarP(&opts.kind, "kind", "k", "helm", "repository kind: argo-template, backstage, coredns, falco, gatekeeper, headlamp, helm, helm-plugin, inspektor-gadget, kcl, keda-scaler, keptn, knative-client-plugin, krew, kubearmor, kubewarden, kyverno, olm, opa, tbaction, tekton-task, tekton-pipeline")
lintCmd.Flags().StringVarP(&opts.path, "path", "p", ".", "repository's packages path")
return lintCmd
}
Expand All @@ -115,6 +115,7 @@ func lint(opts *lintOptions, out *output) error {
hub.Falco,
hub.Gatekeeper,
hub.Headlamp,
hub.InspektorGadget,
hub.KCL,
hub.KedaScaler,
hub.Keptn,
Expand Down Expand Up @@ -619,6 +620,7 @@ func (out *output) printPkgDetails(pkg *hub.Package) {
hub.Falco,
hub.Gatekeeper,
hub.Headlamp,
hub.InspektorGadget,
hub.KCL,
hub.KedaScaler,
hub.Keptn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ returns setof json as $$
or security_report_created_at < (current_timestamp - '1 week'::interval)
)
and r.repository_kind_id <> 13 -- Kubewarden policies are excluded for now
and r.repository_kind_id <> 22 -- Inspektor gadgets are excluded for now
order by s.created_at desc
) s;
$$ language sql;
5 changes: 5 additions & 0 deletions database/migrations/schema/056_inspektor_gadgets.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
insert into repository_kind values (22, 'Inspektor gadgets');

---- create above / drop below ----

delete from repository_kind where repository_kind_id = 22;
28 changes: 28 additions & 0 deletions database/tests/functions/packages/get_snapshots_to_scan.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ select plan(2);
\set repo2ID '00000000-0000-0000-0000-000000000002'
\set repo3ID '00000000-0000-0000-0000-000000000003'
\set repo4ID '00000000-0000-0000-0000-000000000004'
\set repo5ID '00000000-0000-0000-0000-000000000005'
\set package1ID '00000000-0000-0000-0000-000000000001'
\set package2ID '00000000-0000-0000-0000-000000000002'
\set package3ID '00000000-0000-0000-0000-000000000003'
\set package4ID '00000000-0000-0000-0000-000000000004'
\set package5ID '00000000-0000-0000-0000-000000000005'
\set package6ID '00000000-0000-0000-0000-000000000006'
\set package7ID '00000000-0000-0000-0000-000000000007'

-- No snapshots at this point
select is(
Expand All @@ -35,6 +37,8 @@ insert into repository (repository_id, name, display_name, url, scanner_disabled
values (:'repo3ID', 'repo3', 'Repo 3', 'https://repo3.com', true, 0, :'org1ID');
insert into repository (repository_id, name, display_name, url, repository_kind_id, organization_id)
values (:'repo4ID', 'repo4', 'Repo 4', 'https://repo4.com', 13, :'org1ID');
insert into repository (repository_id, name, display_name, url, repository_kind_id, organization_id)
values (:'repo5ID', 'repo5', 'Repo 5', 'https://repo5.com', 22, :'org1ID');
insert into package (
package_id,
name,
Expand Down Expand Up @@ -206,6 +210,17 @@ insert into package (
'1.0.0',
:'repo4ID'
);
insert into package (
package_id,
name,
latest_version,
repository_id
) values (
:'package7ID',
'package7',
'1.0.0',
:'repo5ID'
);
insert into snapshot (
package_id,
version,
Expand All @@ -219,6 +234,19 @@ insert into snapshot (
current_timestamp - '2 weeks'::interval,
'2010-06-16 11:20:30+02'
);
insert into snapshot (
package_id,
version,
containers_images,
ts,
created_at
) values (
:'package7ID',
'1.0.0',
'[{"image": "quay.io/org/pkg6:1.0.0"}]',
current_timestamp - '2 weeks'::interval,
'2010-06-16 11:20:30+02'
);

-- Run some tests
select is(
Expand Down
3 changes: 2 additions & 1 deletion database/tests/schema/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ select results_eq(
(18, 'Argo templates'),
(19, 'KubeArmor policies'),
(20, 'KCL modules'),
(21, 'Headlamp plugins')
(21, 'Headlamp plugins'),
(22, 'Inspektor gadgets')
$$,
'Repository kinds should exist'
);
Expand Down
84 changes: 68 additions & 16 deletions docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1207,13 +1207,13 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/helm/{repoName}/{packageName}":
"/packages/falco/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getHelmPackageDetails
operationId: getFalcoRulesDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
Expand All @@ -1223,20 +1223,20 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/HelmPackage"
$ref: "#/components/schemas/FalcoPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/helm-plugin/{repoName}/{packageName}":
"/packages/gatekeeper/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getHelmPluginDetails
operationId: getGatekeeperPoliciesDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
Expand All @@ -1246,20 +1246,20 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/HelmPluginPackage"
$ref: "#/components/schemas/GatekeeperPolicy"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/falco/{repoName}/{packageName}":
"/packages/headlamp/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getFalcoRulesDetails
operationId: getHeadlampPluginDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
Expand All @@ -1269,20 +1269,20 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/FalcoPackage"
$ref: "#/components/schemas/HeadlampPluginPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/gatekeeper/{repoName}/{packageName}":
"/packages/helm/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getGatekeeperPoliciesDetails
operationId: getHelmPackageDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
Expand All @@ -1292,20 +1292,20 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/GatekeeperPolicy"
$ref: "#/components/schemas/HelmPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/headlamp/{repoName}/{packageName}":
"/packages/helm-plugin/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getHeadlampPluginDetails
operationId: getHelmPluginDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
Expand All @@ -1315,14 +1315,36 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/HeadlampPluginPackage"
$ref: "#/components/schemas/HelmPluginPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/inspektor-gadget/{repoName}/{packageName}":
get:
tags:
- Packages
summary: Get package details
description: Get package details
operationId: getInspektorGadgetDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/InspektorGadgetPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"

"/packages/kcl/{repoName}/{packageName}":
get:
tags:
Expand Down Expand Up @@ -1838,6 +1860,30 @@ paths:
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/inspektor-gadget/{repoName}/{packageName}/{version}":
get:
tags:
- Packages
summary: Get package version details
description: Get package version details
operationId: getInspektorGadgetVersionDetails
parameters:
- $ref: "#/components/parameters/RepoNameParam"
- $ref: "#/components/parameters/PackageNameParam"
- $ref: "#/components/parameters/VersionParam"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/InspektorGadgetPackage"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequests"
"500":
$ref: "#/components/responses/InternalServerError"
"/packages/kcl/{repoName}/{packageName}/{version}":
get:
tags:
Expand Down Expand Up @@ -4036,6 +4082,8 @@ components:
headlamp/plugin/archive-checksum:
type: string
example: "sha256:123456..."
InspektorGadgetPackage:
$ref: "#/components/schemas/Package"
KCLPackage:
$ref: "#/components/schemas/Package"
KedaScalerPackage:
Expand Down Expand Up @@ -4783,6 +4831,7 @@ components:
* `19` - KubeArmor templates
* `20` - KCL packages
* `21` - Headlamp plugins
* `22` - Inspektor gadgets
RepositoryKindParam:
type: string
enum:
Expand All @@ -4808,6 +4857,7 @@ components:
- kubearmor
- kcl
- headlamp
- inspektor-gadget
description: |
Repository kind name:
* `helm` - Helm charts
Expand All @@ -4832,6 +4882,7 @@ components:
* `kubearmor` - KubeArmor policies
* `kcl` - KCL packages
* `headlamp` - Headlamp plugins
* `inspektor-gadget` - Inspektor gadgets
RepositorySummary:
type: object
required:
Expand Down Expand Up @@ -5373,6 +5424,7 @@ components:
* `19` - KubeArmor templates
* `20` - KCL packages
* `21` - Headlamp plugins
* `22` - Inspektor gadgets
PackageNameParam:
in: path
name: packageName
Expand Down
Loading