forked from openclarity/vmclarity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt reconciler logic for orchestrator (openclarity#320)
* refactor: adopt reconcile logic * refactor: Provider interface * rename Client interface to Provider * split Provider interface into Discoverer and Scanner * add FatalError and RetryableError error types to allow the caller to distingiush between recoverable/retryable and unrecoverable/permanent errors returned by the provider. * refactor: rm timeouts for ScanResult * fix: linter errors * feat(aws): wrap permanent errors * fix: linter errors * feat: add helper for unpacking multi-errors * fix(cli): handling ScanResult in DONE state * fix: go.mod * fix(aws): deleting snaphots twice in same region * fix(cli): interval for polling ScanResult * refactor(cli): update logging/error messages * fix: missing /dev mount in scanner container * fix: rm AWS permission used for debugging authn * fix(aws): rm unused function * fix(utils): comments for utils.error package * feat: add comments to schedule module * fix(aws): handling Location for Instance * fix: string representation of reconcile event * fix: comment not ending with period error. * refactor: mk Before After aligned with time.Time
- Loading branch information
1 parent
ea03939
commit 8c87e62
Showing
79 changed files
with
5,961 additions
and
3,851 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright © 2023 Cisco Systems, Inc. and its affiliates. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package models | ||
|
||
type FamilyConfigEnabler interface { | ||
IsEnabled() bool | ||
} | ||
|
||
func (c *VulnerabilitiesConfig) IsEnabled() bool { | ||
return c != nil && c.Enabled != nil && *c.Enabled | ||
} | ||
|
||
func (c *SecretsConfig) IsEnabled() bool { | ||
return c != nil && c.Enabled != nil && *c.Enabled | ||
} | ||
|
||
func (c *SBOMConfig) IsEnabled() bool { | ||
return c != nil && c.Enabled != nil && *c.Enabled | ||
} | ||
|
||
func (c *RootkitsConfig) IsEnabled() bool { | ||
return c != nil && c.Enabled != nil && *c.Enabled | ||
} | ||
|
||
func (c *MisconfigurationsConfig) IsEnabled() bool { | ||
return c != nil && c.Enabled != nil && *c.Enabled | ||
} | ||
|
||
func (c *MalwareConfig) IsEnabled() bool { | ||
return c != nil && c.Enabled != nil && *c.Enabled | ||
} | ||
|
||
func (c *ExploitsConfig) IsEnabled() bool { | ||
return c != nil && c.Enabled != nil && *c.Enabled | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright © 2023 Cisco Systems, Inc. and its affiliates. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package models | ||
|
||
func (s *Scan) GetState() (ScanState, bool) { | ||
var state ScanState | ||
var ok bool | ||
|
||
if s.State != nil { | ||
state, ok = *s.State, true | ||
} | ||
|
||
return state, ok | ||
} | ||
|
||
func (s *Scan) GetID() (string, bool) { | ||
var id string | ||
var ok bool | ||
|
||
if s.Id != nil { | ||
id, ok = *s.Id, true | ||
} | ||
|
||
return id, ok | ||
} | ||
|
||
func (s *Scan) GetScanConfigScope() (ScanScopeType, bool) { | ||
var scope ScanScopeType | ||
var ok bool | ||
|
||
if s.ScanConfigSnapshot != nil { | ||
scope, ok = s.ScanConfigSnapshot.GetScope() | ||
} | ||
|
||
return scope, ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright © 2023 Cisco Systems, Inc. and its affiliates. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package models | ||
|
||
func (s *ScanConfig) GetID() (string, bool) { | ||
var id string | ||
var ok bool | ||
|
||
if s.Id != nil { | ||
id, ok = *s.Id, true | ||
} | ||
|
||
return id, ok | ||
} | ||
|
||
const DefaultMaxParallelScanners int = 2 | ||
|
||
func (s *ScanConfig) GetMaxParallelScanners() int { | ||
if s.MaxParallelScanners != nil { | ||
return *s.MaxParallelScanners | ||
} | ||
|
||
return DefaultMaxParallelScanners | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright © 2023 Cisco Systems, Inc. and its affiliates. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package models | ||
|
||
func (d *ScanConfigSnapshot) GetScope() (ScanScopeType, bool) { | ||
var scope ScanScopeType | ||
var ok bool | ||
|
||
if d.Scope != nil { | ||
scope, ok = *d.Scope, true | ||
} | ||
return scope, ok | ||
} | ||
|
||
func (s *ScanConfigSnapshot) GetMaxParallelScanners() int { | ||
if s.MaxParallelScanners != nil { | ||
return *s.MaxParallelScanners | ||
} | ||
|
||
return DefaultMaxParallelScanners | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright © 2023 Cisco Systems, Inc. and its affiliates. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package models | ||
|
||
func (r *TargetScanResult) GetGeneralState() (TargetScanStateState, bool) { | ||
var state TargetScanStateState | ||
var ok bool | ||
|
||
if r.Status != nil { | ||
state, ok = r.Status.GetGeneralState() | ||
} | ||
|
||
return state, ok | ||
} | ||
|
||
func (r *TargetScanResult) GetGeneralErrors() []string { | ||
var errs []string | ||
|
||
if r.Status != nil { | ||
errs = r.Status.GetGeneralErrors() | ||
} | ||
|
||
return errs | ||
} | ||
|
||
func (r *TargetScanResult) GetID() (string, bool) { | ||
var id string | ||
var ok bool | ||
|
||
if r.Id != nil { | ||
id, ok = *r.Id, true | ||
} | ||
|
||
return id, ok | ||
} | ||
|
||
func (r *TargetScanResult) GetScanID() (string, bool) { | ||
var scanID string | ||
var ok bool | ||
|
||
if r.Scan != nil { | ||
scanID, ok = r.Scan.Id, true | ||
} | ||
|
||
return scanID, ok | ||
} | ||
|
||
func (r *TargetScanResult) GetTargetID() (string, bool) { | ||
var targetID string | ||
var ok bool | ||
|
||
if r.Target != nil { | ||
targetID, ok = r.Target.Id, true | ||
} | ||
|
||
return targetID, ok | ||
} | ||
|
||
func (r *TargetScanResult) IsDone() (bool, bool) { | ||
var done bool | ||
var ok bool | ||
var state TargetScanStateState | ||
|
||
if state, ok = r.GetGeneralState(); ok && state == TargetScanStateStateDONE { | ||
done = true | ||
} | ||
|
||
return done, ok | ||
} | ||
|
||
func (r *TargetScanResult) HasErrors() bool { | ||
var has bool | ||
|
||
if errs := r.GetGeneralErrors(); len(errs) > 0 { | ||
has = true | ||
} | ||
|
||
return has | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright © 2023 Cisco Systems, Inc. and its affiliates. | ||
// All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package models | ||
|
||
func (s *TargetScanState) GetState() (TargetScanStateState, bool) { | ||
var state TargetScanStateState | ||
var ok bool | ||
|
||
if s.State != nil { | ||
state, ok = *s.State, true | ||
} | ||
return state, ok | ||
} | ||
|
||
func (s *TargetScanState) GetErrors() []string { | ||
var errs []string | ||
|
||
if s.Errors != nil { | ||
errs = *s.Errors | ||
} | ||
return errs | ||
} |
Oops, something went wrong.