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

feat: inline auth for MAAS #198

Merged
merged 12 commits into from
Aug 27, 2024
Merged

Conversation

mattwelke
Copy link
Member

@mattwelke mattwelke commented Aug 23, 2024

Issue

Resolves #200

Description

Moves the MAAS API token into the Auth struct so that all required credentials for MAAS are contained in one place.

Also includes a factor. Replaces each init<plugin>rule helper function with one initRule function that uses the new validation rule interface to set the name of each rule, regardless of whether the rule is manually named by users and regardless of which plugin it comes from.

Also updates each plugin to latest version.

@mattwelke mattwelke requested a review from a team as a code owner August 23, 2024 18:33
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 23, 2024
Copy link

gitguardian bot commented Aug 23, 2024

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
13388493 Triggered Generic High Entropy Secret 03c7f48 tests/integration/_validator/testcases/data/validator.yaml View secret
13388493 Triggered Generic High Entropy Secret 03c7f48 hack/validator.tmpl View secret
13388493 Triggered Generic High Entropy Secret 03c7f48 tests/integration/_validator/testcases/data/validator.yaml View secret
13388493 Triggered Generic High Entropy Secret 03c7f48 hack/validator.tmpl View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
@mattwelke mattwelke force-pushed the refactor/use-validation-rule-interface branch from 5d1f150 to 3a4d248 Compare August 23, 2024 19:05
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
@mattwelke mattwelke force-pushed the refactor/use-validation-rule-interface branch from 3ae1d6a to 2ddb989 Compare August 23, 2024 19:13
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
Copy link

codecov bot commented Aug 25, 2024

Codecov Report

Attention: Patch coverage is 65.38462% with 27 lines in your changes missing coverage. Please review.

Files Patch % Lines
pkg/services/validator/vmware.go 50.00% 3 Missing and 10 partials ⚠️
pkg/services/validator/rule_names.go 42.85% 6 Missing and 2 partials ⚠️
pkg/services/validator/maas.go 44.44% 5 Missing ⚠️
pkg/services/clouds/maas_service.go 75.00% 0 Missing and 1 partial ⚠️
@@            Coverage Diff             @@
##             main     #198      +/-   ##
==========================================
- Coverage   53.52%   53.38%   -0.15%     
==========================================
  Files          44       45       +1     
  Lines        6294     6223      -71     
==========================================
- Hits         3369     3322      -47     
+ Misses       2076     2063      -13     
+ Partials      849      838      -11     
Files Coverage Δ
pkg/cmd/validator/validator.go 58.51% <100.00%> (ø)
pkg/components/validator.go 58.38% <100.00%> (ø)
pkg/services/validator/aws.go 50.21% <100.00%> (-0.65%) ⬇️
pkg/services/validator/azure.go 40.78% <100.00%> (-0.20%) ⬇️
pkg/services/validator/network.go 47.01% <100.00%> (+0.03%) ⬆️
pkg/services/validator/oci.go 46.46% <100.00%> (+0.03%) ⬆️
...integration/_validator/testcases/test_validator.go 93.68% <ø> (-0.02%) ⬇️
pkg/services/clouds/maas_service.go 55.29% <75.00%> (ø)
pkg/services/validator/maas.go 45.00% <44.44%> (-1.39%) ⬇️
pkg/services/validator/rule_names.go 42.85% <42.85%> (ø)
... and 1 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f43a5ba...db942b6. Read the comment docs.

@mattwelke
Copy link
Member Author

Commits finished, ready for review.

pkg/components/validator.go Outdated Show resolved Hide resolved
mattwelke and others added 5 commits August 26, 2024 19:17
Replace VsphereEntityPrivilegeRule with v1alpha1.EntityPrivilegeValidationRule from plugin. Replace VsphereRolePrivilegeRule with v1alpha1.GenericRolePrivilegeValidationRule from plugin. Replace VsphereTagRule with v1alpha1.TagValidationRule from plugin. Remove top level rule slice fields from Vsphere plugin config struct. Refactor Vsphere prompt code to only fill in the rules nested within the  field of the plugin config struct, not duplicating them in the now-removed top level rule slice fields of the plugin config struct.

Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 27, 2024
@mattwelke mattwelke changed the title refactor: use validation rule interface feat: inline auth for MAAS Aug 27, 2024
@mattwelke mattwelke merged commit ed78617 into main Aug 27, 2024
8 checks passed
@mattwelke mattwelke deleted the refactor/use-validation-rule-interface branch August 27, 2024 20:53
TylerGillson added a commit that referenced this pull request Sep 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.1.3](v0.1.2...v0.1.3)
(2024-09-03)


### Features

* inline auth for MAAS
([#198](#198))
([ed78617](ed78617))
* support Azure plugin community gallery image rule
([#181](#181))
([3d20725](3d20725))


### Bug Fixes

* ensure ErrValidationFailed is returned for maas direct validation
failures
([#179](#179))
([0e0e7b9](0e0e7b9))
* handle validation errors, result count mismatch
([#204](#204))
([a2ea08b](a2ea08b))
* only require docker, kind when provisioning kind cluster
([#180](#180))
([1bbdb0e](1bbdb0e))
* remove duplicate maas base values from template
([#182](#182))
([cfa39a8](cfa39a8))
* support `validator rules check -f config.yaml` without all plugins
defined
([#191](#191))
([6829834](6829834))


### Other

* cleanup comment
([#176](#176))
([f371927](f371927))


### Dependency Updates

* **deps:** update anchore/sbom-action action to v0.17.2
([#184](#184))
([00d3a5c](00d3a5c))
* **deps:** update github.com/validator-labs/validator-plugin-maas
digest to e903cc7
([#175](#175))
([09c3ad1](09c3ad1))
* **deps:** update golang.org/x/exp digest to 9b4947d
([#190](#190))
([8c427e9](8c427e9))
* **deps:** update module github.com/canonical/gomaasclient to v0.7.0
([#197](#197))
([f43a5ba](f43a5ba))
* **deps:** update module github.com/validator-labs/validator to v0.1.8
([#120](#120))
([fe587c6](fe587c6))
* **deps:** update module github.com/vmware/govmomi to v0.42.0
([#172](#172))
([f0488c9](f0488c9))


### Refactoring

* move vsphere account under auth to match new plugin api
([#189](#189))
([90352e1](90352e1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer refactoring Refactoring / tech debt size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🌱 Support inline auth for MAAS in addition to k8s secret
3 participants