Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- moves some types into a separate file - addresses some linter/staticcheck issues - fixes bad counter
- Loading branch information
Willie Sana
committed
Aug 10, 2020
1 parent
aa98f2e
commit 900a5d6
Showing
6 changed files
with
92 additions
and
68 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
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,62 @@ | ||
/* | ||
Copyright (C) 2020 Accurics, Inc. | ||
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 opa | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/accurics/terrascan/pkg/results" | ||
|
||
"github.com/open-policy-agent/opa/rego" | ||
) | ||
|
||
// RegoMetadata The rego metadata struct which is read and saved from disk | ||
type RegoMetadata struct { | ||
RuleName string `json:"ruleName"` | ||
File string `json:"file"` | ||
RuleTemplate string `json:"ruleTemplate"` | ||
RuleTemplateArgs map[string]interface{} `json:"ruleTemplateArgs"` | ||
Severity string `json:"severity"` | ||
Description string `json:"description"` | ||
RuleReferenceID string `json:"ruleReferenceId"` | ||
Category string `json:"category"` | ||
Version int `json:"version"` | ||
} | ||
|
||
// RegoData Stores all information needed to evaluate and report on a rego rule | ||
type RegoData struct { | ||
Metadata RegoMetadata | ||
RawRego []byte | ||
PreparedQuery *rego.PreparedEvalQuery | ||
} | ||
|
||
// EngineStats Contains misc stats | ||
type EngineStats struct { | ||
ruleCount int | ||
regoFileCount int | ||
metadataFileCount int | ||
metadataCount int | ||
} | ||
|
||
// Engine Implements the policy engine interface | ||
type Engine struct { | ||
Context context.Context | ||
RegoFileMap map[string][]byte | ||
RegoDataMap map[string]*RegoData | ||
ViolationStore *results.Store | ||
stats EngineStats | ||
} |
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