-
Notifications
You must be signed in to change notification settings - Fork 550
feat: Policy Snapshot Testing #449
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
Merged
Merged
Changes from all commits
Commits
Show all changes
125 commits
Select commit
Hold shift + click to select a range
e5b34d5
add new policy Filter
bbernays 3d592d7
Add tests for p.Filter
bbernays 85cb429
Support Filtering on describe
bbernays 5f796f2
Update client.go
bbernays fb55171
Update client.go
bbernays a668055
Add Support for Check level filter
bbernays 33cdb91
Update execute.go
bbernays 611dbc8
Update manager.go
bbernays 7664fa2
Update execute_test.go
bbernays 048514b
Update policy.go
bbernays 0d81b2f
Update execute.go
bbernays 04702a4
Merge branch 'main' into Remove-filtering-from-executor
bbernays 1a8cacd
Update execute_test.go
bbernays 4dfa7f1
Merge branch 'Remove-filtering-from-executor' of https://github.com/b…
bbernays d4159cc
Update execute.go
bbernays 2785416
Update manager.go
bbernays d782e63
Tests pass locally
bbernays 3d215b1
Loca
bbernays eac026b
Update execute_test.go
bbernays 4a84f41
Update execute.go
bbernays 1475447
Update execute.go
bbernays 3cb27af
Update manager.go
bbernays f280c6b
Update execute_test.go
bbernays 3e77b68
Create parse.go
bbernays 48a0673
Update go.mod
bbernays 17d0cf6
Update go.sum
bbernays 39e063d
Create database
bbernays 983a3d2
Create manager.go
bbernays 1e56d1e
change package
bbernays 0f37ba0
Update go.mod
bbernays 0b2c2b6
Update go.sum
bbernays 6b59dd4
Create policy_snapshot.go
bbernays 06512e1
Update client.go
bbernays bcb6636
Create db.go
bbernays 833e10e
Update policy_snapshot.go
bbernays 72deb3d
Update policy.go
bbernays c6032ca
Update client.go
bbernays e391aa5
Update policy.go
bbernays eb5e32b
checkpoint
bbernays c99612a
discard old format
bbernays 5b89698
Update execute.go
bbernays 73a4cc2
Update snapshots.go
bbernays 29e0d7a
Update snapshots.go
bbernays 54143ce
Update manager.go
bbernays 780f7fb
Update client.go
bbernays 1903671
Update manager.go
bbernays 2c284d9
Update client.go
bbernays 53ad65f
parse dsn
bbernays 8097869
Update snapshots.go
bbernays 8192b8e
Update snapshots.go
bbernays ddf1616
Dump Views
bbernays 2af12de
Working
bbernays 58f3e02
Update snapshots.go
bbernays b1cc71f
Update client.go
bbernays b50d065
Merge branch 'main' into Policy-Testing
bbernays a8b99a7
Update snapshots.go
bbernays 0bf6afc
Merge branch 'main' into Policy-Testing
bbernays 4b91e32
Update manager.go
bbernays 1b096ed
runner
bbernays cb47da6
Update helper.go
bbernays 54cdd09
Update helper.go
bbernays 0ccd6ea
Update helper_test.go
bbernays 17429de
Update helper.go
bbernays 269252a
Update snapshots.go
bbernays 76adc13
snapshot
bbernays cbfd99d
Update snapshots.go
bbernays 57e1475
Update helper.go
bbernays 677ce28
push
bbernays 4dd5995
Update helper.go
bbernays b90099e
Update helper_test.go
bbernays 3ccfd26
Update helper_test.go
bbernays d584073
Update helper.go
bbernays 3981028
Update helper.go
bbernays 596339a
Update client.go
bbernays e19ff91
Merge branch 'cloudquery:main' into Test-Runner
bbernays d0a8c82
Update client.go
bbernays 2a56f67
Refactor
bbernays 12535bf
Update client.go
bbernays a42b3da
Update .gitignore
bbernays d5b0ce5
Update execute.go
bbernays bd9dd77
Update manager.go
bbernays 69bacec
Update snapshots.go
bbernays 0e9044a
Update helper.go
bbernays 7a8999d
Update helper_test.go
bbernays 9842897
Merge branch 'main' into Test-Runner
bbernays 59451e7
Use new version of CloudQuery SDK
bbernays 822975c
use new version of cq-provider-sdk
bbernays 0f85f3e
Make compile
bbernays bce29a1
refactor
bbernays e4aa99e
update go mod
bbernays 64757a3
Merge branch 'cloudquery:main' into Test-Runner
bbernays 6b337f5
Update helper_test.go
bbernays 9f69d92
cleanup
bbernays f0a779d
Merge branch 'main' into Test-Runner
bbernays 241c9bd
Merge branch 'cloudquery:main' into Test-Runner
bbernays 2633b4d
Add `cq policy test` command
bbernays 272f77b
Change path to be selector
bbernays 9492e14
replace temp file
bbernays 7f1e7be
move file to policy package
bbernays 8e62eb1
Update client.go
bbernays 4e4fd83
Update manager.go
bbernays 124dfc7
remove extra args
bbernays 0c76799
Update client.go
bbernays a2aaae7
Update client.go
bbernays 6505bae
rename
bbernays 9c73a88
Create snapshot_testing_test.go
bbernays 910dc48
Update snapshot_testing.go
bbernays 407cdae
Respond to comments
bbernays f2adfbf
Update manager.go
bbernays 2a81c91
Update snapshots.go
bbernays 25fde86
Update snapshot_testing.go
bbernays e3ea87d
Update snapshots.go
bbernays 02ad178
Update snapshots.go
bbernays 5d03336
Update snapshot_testing_test.go
bbernays 3b7814c
Update snapshot_testing_test.go
bbernays ad1791a
Merge branch 'main' into Test-Runner
bbernays 5d1c7c3
Update drift.go
bbernays 9ca9429
Update policy_snapshot.go
bbernays e31fdea
Update client.go
bbernays 4b0db2d
Update snapshot_testing_test.go
bbernays a7da214
Update snapshots.go
bbernays 7fad746
respond to comments
bbernays 0dcf17a
Update snapshot_testing.go
bbernays f74d34c
Refactor
bbernays f26043f
nits
bbernays File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -21,4 +21,5 @@ config.hcl | |
| config_old.hcl | ||
| /pkg/policy/tests/output/ | ||
| /pkg/policy/cq/* | ||
| database-data/* | ||
| database-data/* | ||
| dest/* | ||
This file contains hidden or 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,27 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/cloudquery/cloudquery/pkg/ui/console" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| const policySnapshotHelpMsg = `Take database snapshot of all tables included in a CloudQuery policy` | ||
|
|
||
| var ( | ||
| snapshotPolicyCmd = &cobra.Command{ | ||
| Use: "snapshot", | ||
| Short: policySnapshotHelpMsg, | ||
| Long: policySnapshotHelpMsg, | ||
| Args: cobra.ExactArgs(2), | ||
| Run: handleCommand(func(ctx context.Context, c *console.Client, cmd *cobra.Command, args []string) error { | ||
| return c.SnapshotPolicy(ctx, args[0], args[1]) | ||
| }), | ||
| } | ||
| ) | ||
|
|
||
| func init() { | ||
| snapshotPolicyCmd.SetUsageTemplate(usageTemplateWithFlags) | ||
| policyCmd.AddCommand(snapshotPolicyCmd) | ||
| } |
This file contains hidden or 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 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/cloudquery/cloudquery/pkg/ui/console" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| const policyTestHelpMsg = "Tests policy against a precompiled set of database snapshots" | ||
|
|
||
| var ( | ||
| policyTestCmd = &cobra.Command{ | ||
| Use: "test", | ||
| Short: policyTestHelpMsg, | ||
| Long: policyTestHelpMsg, | ||
| Example: ` | ||
| # Download & Run the policies defined in your config | ||
| cloudquery policy test path/to/policy.hcl path/to/snapshot/dir selector | ||
| `, | ||
| Run: handleCommand(func(ctx context.Context, c *console.Client, cmd *cobra.Command, args []string) error { | ||
| return c.TestPolicies(ctx, args[0], args[1]) | ||
| }), | ||
| Args: cobra.ExactArgs(2), | ||
| } | ||
| ) | ||
|
|
||
| func init() { | ||
| flags := policyTestCmd.Flags() | ||
| flags.StringVar(&outputDir, "output-dir", "", "Generates a new file for each policy at the given dir with the output") | ||
| flags.BoolVar(&noResults, "no-results", false, "Do not show policies results") | ||
| policyRunCmd.SetUsageTemplate(usageTemplateWithFlags) | ||
| policyCmd.AddCommand(policyTestCmd) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.