394 Commits

Author SHA1 Message Date
jdesouza
a5af7bb34e INS-1950: Go 1.26 and bump libs for polaris (#1172)
* Go 1.26

* Go 1.26

* Go 1.26

* Go 1.26
2026-02-24 12:22:14 -03:00
Vitor Rodrigo Vezani
38e540e0cf Remove flags from audit command and remove auth command (#1138)
* update libs

* Remove unused authentication code and dependencies from the Polaris project, streamlining the audit process by eliminating the upload insights feature and related flags.

* remove insights reporter

* remove lingering libs

* update docs

* INS-1251: Polaris: upgrade github.com/qri-io/jsonschema to v0.2.1 (#1135)

* Bump lins

* Code refactoring

* Fixign issues

* Fixing issues

* Fixing issues

* Fixing issues

* [WIP]

* [WIP]

* [WIP]

* Trying to fix tests

* Trying to fix tests

* Fixing issues

* Fixing issues

* Fixing issues

* Fixing issues

* Fixing issues

* Fixing issues

* Revert go mod

* Revert go mod

* Revert go mod

* Revert go mod

* Fixing issues

* Fixing issue

* Code refactoring

* Updating json schema version

* Updating json schema version

* fix go mod

* fix go sum

---------

Co-authored-by: jdesouza <james@fairwinds.com>
2025-07-24 16:48:23 -03:00
jdesouza
2b17c31957 INS-1251: Polaris: upgrade github.com/qri-io/jsonschema to v0.2.1 (#1135)
* Bump lins

* Code refactoring

* Fixign issues

* Fixing issues

* Fixing issues

* Fixing issues

* [WIP]

* [WIP]

* [WIP]

* Trying to fix tests

* Trying to fix tests

* Fixing issues

* Fixing issues

* Fixing issues

* Fixing issues

* Fixing issues

* Fixing issues

* Revert go mod

* Revert go mod

* Revert go mod

* Revert go mod

* Fixing issues

* Fixing issue

* Code refactoring

* Updating json schema version

* Updating json schema version
2025-07-24 13:46:37 -03:00
jdesouza
813d9c0a2a INS-1097: Fix CVE-2025-22874 for polaris (#1122)
* Bumping polaris libs

* Fixing lint

* Fixed vuln

* Fixed vuln

* Fixed vuln

* Fixed vuln
2025-06-17 08:58:10 -03:00
jdesouza
d7d30ac611 INS-933 - pullPolicyNotAlways is crashing webhook mutations (#1115)
* Debugging

* Debugging

* Trying to fix

* Revert

* Debugging

* Debugging

* Debugging

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue
2025-04-21 17:07:12 -03:00
youM
d70591b1b8 fixed pdbMinAvailableGreaterThanHPAMinReplicas and added validation for pdbMinAvailableEqualToHPAMinReplicas. (#1073)
* rename pdbMinAvailableGreaterThanHPAMinReplicas to pdbMinAvailableGreaterThanOrEqualToHPAMinReplicas

* modify doc

* Revert "modify doc"

This reverts commit faffffc298cde23a99c5e19528123f249d92d314.

* Revert "rename pdbMinAvailableGreaterThanHPAMinReplicas to pdbMinAvailableGreaterThanOrEqualToHPAMinReplicas"

This reverts commit b93f283acc279b90c7e7a9d8dbbe53b2f8ab9a31.

* fix test

* fix impl
2025-04-14 11:36:32 -03:00
jdesouza
4dd3a81bbd INSIGHTS-475 Add 3 new checks to polaris (#1082)
* INSIGHTS-448 Add Two Polaris Checks

* Added another chec

* Added another chec

* Added another chec

* Added another chec

* Added another chec

* Added another chec

* Fixing issue

* Fixing issue

* Added another validation

* Added some tests cases

* Added some tests cases

* Update pkg/config/checks/hostProcess.yaml

* Update pkg/validator/pod_test.go

---------

Co-authored-by: Andy Suderman <andy@fairwinds.com>
2024-11-13 08:24:37 -03:00
Vitor Rodrigo Vezani
073847559a Add --merge-config flag to support merging with default configuration (#1075)
* add config merge support

* fix indentation

* Update cmd/polaris/root.go

Co-authored-by: Andy Suderman <andy@fairwinds.com>

---------

Co-authored-by: Andy Suderman <andy@fairwinds.com>
2024-10-22 15:31:18 -03:00
Grégoire Martini
9b5438d864 Fix: rolebindingRolePodExecAttach check (#1070)
* Fix: rolebindingRolePodExecAttach check

Fix the case of a RoleBinding that points to a ClusterRole.
In that case, we ignore the RoleBinding since it will be evaluated by the rolebindingClusterRolePodExecAttach check.

* add tests for role-binding that uses a cluster-role binding

---------

Co-authored-by: Vitor Vezani <vitor.vezani@fairwinds.com>
2024-10-02 10:43:24 -06:00
jdesouza
8d5247e501 INSIGHTS-358 Bump polaris libs (#1068)
* Bumped libs

* Bumped libs

* Fixed issues

* Fixed issues

* Fixed issues

* Fixed issues

* Fixed issues

* Fixed issues

* Fixed issues

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issue

* Fixing issues

* Fixing issues

* Fixing issues

* Fixing issues

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix releaser

* Trying to fix

* Trying to fix

* Trying to fix

* Trying to fix

* Trying to fix

* Trying to fix

* Trying to fix
2024-09-18 17:07:50 -03:00
jdesouza
cb7c10d288 INSIGHTS-8 Polaris: Harden admission against rogue pods (#1064)
* INSIGHTS-8 Polaris: Harden admission against rogue pods

* INSIGHTS-8 Polaris: Harden admission against rogue pods

* INSIGHTS-8 Polaris: Harden admission against rogue pods

* Adding validation

* Adding validation

* Fixing owners
2024-09-09 11:00:06 -03:00
Vitor Rodrigo Vezani
1c1e990454 fix pdbMinAvailableGreaterThanHPAMinReplicas check when minAvailable is not present (#1062) 2024-07-18 13:26:30 -03:00
Vitor Rodrigo Vezani
952b6aed65 INSIGHTS-157 - PDB <> HPA check (#1057)
* fix typo

* fix failure message

* fix changelog

* fix missingPodDisruptionBudget validation

* add tests for pdbMinAvailableLessThenHPAMaxReplicas

* add simple success test

* fix typo

* lowercasing warnings

* WIP implement pdbMinAvailableLessThanHPAMaxReplicas

* change check name

* rename testes

* fix check message

* change check name

* minor fixes

* improving tests

* improve tests

* fix check name

* Update docs/checks/reliability.md

Co-authored-by: Andy Suderman <andy@fairwinds.com>

* fix/add tests

* fixes from PR

* fix error message

---------

Co-authored-by: Andy Suderman <andy@fairwinds.com>
2024-07-08 14:47:54 -03:00
Vitor Rodrigo Vezani
61e0d34e8b INSIGHTS-156 - Fix typo and improve failure message (#1055)
* fix typo

* fix failure message

* fix changelog

* fix missingPodDisruptionBudget validation

* Update failure.empty-labels.yaml

* Update failure.no-metadata.yaml

* INSIGHTS-159 - use go templating instead of custom function validation (#1056)

* use go templating instead of custom function validation

* fix changelog
2024-06-27 17:10:21 -03:00
Vitor Rodrigo Vezani
8b236c2fa2 INSIGHTS-159 - use go templating instead of custom function validation (#1056)
* use go templating instead of custom function validation

* fix changelog
2024-06-27 17:01:59 -03:00
Vitor Rodrigo Vezani
2d33bf2565 INSIGHTS-90 - implement HPA minAvailable and HPA maxAvailable checks (#1053)
* implement minAvailable and maxAvailable checks

* fix tests

* update hpaMaxAvailability check
2024-06-26 17:31:35 -03:00
Vitor Rodrigo Vezani
a81bd29674 Fix comments handling in addOrReplaceValue function (#1039) 2024-03-15 11:43:35 -03:00
Vitor Rodrigo Vezani
ac638e01ba FWI-5820 - remove packr in favor of go:embed (#1035)
* move dashboard to embed

* use embed in favor of packr

* fix references

* Fix error creating router in dashboard.go

* create default config

* remove examples/config.yaml
2024-03-12 16:11:07 -03:00
Vitor Rodrigo Vezani
4a0713c754 FWI-5804 - expose issue fixer and mutations in the library (#1032)
* Add local path replacement for Polaris module

* expose fix.Execute

* Remove local module replacement in go.mod

* Fix error handling and return error instead of exiting the program
2024-03-08 13:23:33 -03:00
Takumi Sue
48fc87a663 Fix trying to list cluster-level resources (#1004)
when namespace specified

close #984
2024-03-05 10:19:02 -05:00
jdesouza
f295dd0fb5 Using controller-utils to get workloads (#1012)
* Using controller-utils to get workloads

* Code cleanup
2023-11-01 15:59:46 -03:00
Robert Brennan
97687761a7 Fix numerical resource ranges (#991)
* fix numerical resource numbers

* add resource range tests
2023-09-05 11:15:45 -06:00
Andrew Suderman
e7eb079921 change kubernetes.io/ label from name to instance (#973)
* Fix #972 change label from name to instance

* Fix tests

* more references

* fix check

* Fix example config
2023-07-13 11:33:15 -06:00
John Slivka
b0d86cdcd2 Add option to filter audit results by severity level (#969) 2023-06-28 08:38:47 -05:00
Robert Brennan
4ca4c8f0f5 Fix nil pointer issue with webhook (#966)
* update

* update go mod

* tidy

* revert go mod

* fix port

* move pod test case

* downgrade controller-runtime

* revert updates

* fix nil pointer

* add logs

* fix var

* remove test requirement

* fix decoder

* fix mutate

* fix test case

* fix logs

* fmt

* fix owned pods in mutate

* fix test

* add logs

* add mutations to tests

* convert to json for patch

* fix up tests

* remove nil check

* fix logs

* add logs

* add env vars to webhook tests
2023-06-22 13:22:19 -04:00
Vitor Rodrigo Vezani
4b1d6635e0 add test for required fields on builtin checks (#965) 2023-06-21 12:25:44 -04:00
Vitor Rodrigo Vezani
07747d76f2 tweak net listener to localhost - removing unwanted popup (#955) 2023-06-09 16:01:59 -03:00
Robert Brennan
8bfed75498 Minor fixes for NSA checks (#952)
* fix rbac checks

* fix sensitive env var check

* add test case

* fix service account check

* fix comment

---------

Co-authored-by: Andrew Suderman <andy@fairwinds.com>
2023-06-09 12:35:36 -06:00
Vitor Rodrigo Vezani
8e3cf1ddd9 FWI-4190 - Upload polaris results to Fairwinds Insights support (#948)
* add login flow

* add logout functionality

* improve code

* implement token and status print

* implement status command

* add user to login

* improve server port management

* improve login flow

* fix login flow

* make insights URL for login configurable

* remove comments

* fix logrus directive usage

* add upload-insights command

* remove unnecessary usage of pointer

* error when using upload-insights and audit-path simultaneously

* upload-insights support

* set priority to reports

* adds report verification

* fix logging to meet expected results

* renaming variable name

* improve results printing

* improve variable naming

* remove TODO

* Update checks severities (#950)

* change all ignore checks to warning

* promoting checks initially warning that should be danger.

* fixing docs and examples

* adds changelog

* fix changelog version

* improve general error message

* update workloads to be able grab its version

* print URL on stdout on browser error

* use os.WriteFile instead of low-level API

* renaming fn params

* add insights client

* validating token on auth status

* minor fix

* only query for re-auth if token is still valid

* update some dependencies in go and CI (#951)

* update some dependencies

* update testing requirements

* Fix cert-manager

* lots of deprecated versions

* attempts

* review suggestions

* avoid nil pointer

* fix fixtures

* fix test

---------

Co-authored-by: Robert Brennan <contact@rbren.io>

* update changelog

---------

Co-authored-by: Andrew Suderman <andy@fairwinds.com>
Co-authored-by: Robert Brennan <contact@rbren.io>
2023-06-06 13:51:42 -03:00
Andrew Suderman
f1bbe9236b update some dependencies in go and CI (#951)
* update some dependencies

* update testing requirements

* Fix cert-manager

* lots of deprecated versions

* attempts

* review suggestions

* avoid nil pointer

* fix fixtures

* fix test

---------

Co-authored-by: Robert Brennan <contact@rbren.io>
2023-06-06 12:01:20 -04:00
Stevie
2d28ea551a sc/rd 71 add plg link (#896)
* Add persistentpostrun to root cmd and postrun to version cmd

* Change PLG link

* Add PLG link to dashboard

* <strong> the link

Co-authored-by: Andrew Suderman <andy@suderman.dev>
2023-01-05 09:33:45 -05:00
Andrew Suderman
a1b63ac417 Fix #547 - add a check for topologySpreadConstraint (#879) 2023-01-04 14:05:23 -07:00
Robert Brennan
8af4363672 update dependencies (#898) 2023-01-04 10:10:09 -05:00
Eng Zer Jun
8bc1a4bcde refactor: move from io/ioutil to io and os packages (#858)
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Co-authored-by: Andrew Suderman <andrew@sudermanjr.com>
2022-11-16 16:28:09 -05:00
ivanfetch-fw
467d06f4db FWI-2719: Enable new RBAC / sensitive content / Pod exec checks, add hasPrefix and hasSuffix functions to the GO template, exempt system: name prefixes for RBAC checks, sensitive content checks ignore valueFrom, (#832)
* Enable these checks in the default configuration file, which may produce many new results:
  * automountServiceAccountToken
  * linuxHardening
  * sensitiveConfigmapContent and sensitiveContainerEnvVar
  * clusterrolebindingClusterAdmin, rolebindingClusterAdminClusterRole, and rolebindingClusterAdminRole
  * clusterrolePodExecAttach, rolePodExecAttach, clusterrolebindingPodExecAttach, rolebindingClusterRolePodExecAttach, and  rolebindingRolePodExecAttach
* Ignore the `missingNetworkPolicy` and `automountServiceAccountToken` checks by default
* `hasPrefix` and `hasSuffix` functions are now available in the go template
* Fix the `sensitiveContainerEnvVar` check to ignore sensitive environment
variable names when those variables use `valueFrom` to reference an
external resource.
* Add the `*ClusterAdmin` checks to `examples/config-full.yaml`.
* Exempt the prefix `system:` instead of individual entries for RBAC checks (#871)
2022-11-14 15:05:02 -07:00
ivanfetch-fw
45be5cbbef FWI-2912: Add logging to improve debugging of JSON Schema (#859)
* Add debug logging for JSON Schema validation and Go templating

* Fix `--help` to display the full Polaris usage

* add valid log possible levels to `--log-level` flag help
2022-10-05 11:22:42 -06:00
Robert Brennan
8e7100acaf Add debug info to kube resources, better caching strategy (#840)
* add debug info

* remove extra build step

* try and fix memory usage

* fix pointers

* add more debug logs

* fix up caching for replicasets

* fix import

* replace info with debug

* add logs

* dont cache jobs

* gofmt

* fix import
2022-09-16 10:07:20 -04:00
Barnabas Makonda
4d96993a18 [FWI-2357] Let Polaris modify YAML without losing comments/formatting (#821)
* added fix command implementation

* use node api

* fix tests

* added hostport mutate rule

* update mutating server

* fix array reference and add back leading slash

* added test and refactor findNodes

* more tests

* added more test and fix issue with arrays

* rename findNode function and ensure we capture exceptions

* rename findNode function

* append array value at the end and for single item remove brackets

* append array value at the end and for single item remove brackets

* create array if it does not exists

* fix tests

* handle some exceptions

* fix tests

* fix string format

* guard for PodResult

* fix flag name

* fix privilegeEscalation check

* fix up mutations for local files

* fix pod parsing

* fix object values

* remove logspam

* fix import

* update some comments for health probes

* add an option to not apply any mutations\, and just adjust yaml formatting

* add preliminary support for helm

* logspam

* change up comment strategy

* fix object comments

* format

* fix tests

* add comments

* fix key updates

* fix mutation tests

* tidy

* refactor test

* add test

* add test

* add test for object comments

Co-authored-by: Robert Brennan <accounts@rbren.io>
Co-authored-by: Robert Brennan <contact@rbren.io>
2022-09-15 12:38:22 -04:00
Robert Brennan
1486e3090f Add warning message for multi-schema checks in admission (#839)
* make cert dir option

* log message for multi-resource checks in admission

* Update pkg/validator/schema.go

Co-authored-by: Andrew Suderman <andrew@sudermanjr.com>
2022-09-14 09:01:27 -06:00
Igor Beliakov
01dd7b7b68 Omit empty results, make pretty output less verbose (#767)
* Pretty output: remove 2 leading line breaks and 1 trailing after container results

Signed-off-by: Igor Beliakov <demtis.register@gmail.com>

* validator: don't add empty results in ApplyAllSchemaChecksToAllResources

Signed-off-by: Igor Beliakov <demtis.register@gmail.com>

* Fix MockPod() fixture:
- Since now result is considered non-empty only if Kind and Name are set, needed to adjust MockPod() to make it contain Name.

Signed-off-by: Igor Beliakov <demtis.register@gmail.com>

Co-authored-by: Robert Brennan <accounts@rbren.io>
2022-08-25 10:34:06 -04:00
ivanfetch-fw
01d7a8ac00 FWI-2547: Add checks for RBAC allowing execing or attaching to a Pod (#820)
* Add `rolePodExecAttach` and `clusterrolePodExecAttach` checks

* Add schema tests

* Add clusterrolebindingPodExecAttach, rolebindingRolePodExecAttach, and rolebindingClusterRolePodExecAttach checks + schema-tests

* Add the new checks to the full example config

* Update checks' success/failure messages and add some helpful comments

* Update binding-related check messaging RE: roleRef pointing to a nonexistent resource, and add tests for this case

* Update rolebindingClusterRolePodExecAttach and rolebindingRolePodExecAttach to pass if a binding roleRef is a different kind, and schema tests to include a namespace

* Add additional schema tests, remove "ignore default ClusterRole|Role bindings" code from checks that actually have no default bindings
2022-08-23 12:09:44 -06:00
ivanfetch-fw
742b21c6a2 FWI-2582: Add clusterrolebindingClusterAdmin, rolebindingClusterAdminRole, and rolebindingClusterAdminClusterRole checks + schema tests (#823)
* Add `clusterrolebindingClusterAdmin`, `rolebindingClusterAdminRole`, and `rolebindingClusterAdminClusterRole` checks + schema tests

* Update `rolebindingClusterAdminClusterRole` check to explicitly match the `cluster-admin` default ClusterRole, fix `...all_verbs` schema test, add schema checks for unrelated permissions
2022-08-22 09:50:58 -06:00
ivanfetch-fw
e3a6cb3774 Fix namespace checking when validating additional schemas which are not namespaced (#822) 2022-08-18 18:34:32 -06:00
ivanfetch-fw
206322271c FWI-2509: Add sensitiveContainerEnvVar and sensitiveConfigMapContent checks (#817)
* Add sensitiveContainerEnvVar and sensitiveConfigMapContent checks

* Update full example configfile
2022-08-05 11:58:57 -04:00
ivanfetch-fw
e5b9236268 FWI-2476: Add missingNetworkPolicy, automountServiceAccountToken, and linuxHardening checks (#816)
* Add missingNetworkPolicy, automountServiceAccountToken, and linuxHardening checks
2022-08-05 09:44:18 -06:00
ivanfetch-fw
c3b57bf6c7 target: container also populates .Polaris.PodSpec|PodTemplate + a new .Polaris.Container representing the currently checked container, GetPodTemplate serializes data to work around a DeepCopy bug with type int (#812) 2022-07-29 07:45:56 -06:00
Igor Beliakov
652b65b3c2 fix: properly remove emojis in pretty format with no color (#765)
Signed-off-by: Igor Beliakov <demtis.register@gmail.com>

Co-authored-by: Robert Brennan <accounts@rbren.io>
2022-07-28 15:39:17 -04:00
Igor Beliakov
a0000e1919 Suppress empty results when --only-show-failed-tests is passed (#811)
* Suppress empty results when --only-show-failed-tests is passed

Signed-off-by: Igor Beliakov <demtis.register@gmail.com>

* Fix remaining typo

Signed-off-by: Igor Beliakov <demtis.register@gmail.com>

Co-authored-by: Robert Brennan <accounts@rbren.io>
2022-07-26 09:31:08 -04:00
ivanfetch-fw
50d789fd42 Fix resourceKindMap.addResource() to not assume every Kind has an APIGroup (#805)
This was causing the `ResourceProvider.Resources` map to essentially
loose resources with no APIGroup, such as ServiceAccounts.
2022-07-15 13:53:41 -06:00
ivanfetch-fw
be45519a22 Add target PodTemplate which exposes the full Pod (not only the spec) (#801)
* Add `target PodTemplate` which exposes the full Pod (not only the spec)

* Fix PotTemplate in conjunction with how pod-schema-checks are handled

* Add test for GO template `Polaris` sub-keys, help `NewGenericResourceFromPod` to set `PodTemplate` in more cases

* Clarify PldTemplate logic for `IsActionable()`
2022-07-14 12:51:24 -06:00