-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added custom config * first lint fix * Revert "first lint fix" This reverts commit d949e4b. * changed CI and makefile command * switched OPA to regal in CI * add lint check rule to makefile * renaming on the way, added a readme * compiling * moved buildChainAccount to entity query lib * desactivated some rules - compiled and lint * test passing - lint check seem ok * format and re-added format check for rego * re-setup opa formatter in CI * rerun format * annotate 'evaluate' rule * removed lint rules for no entrypoint * format config.yaml * reactivated linter on full rego, moved main so that it's recognized in engine * remove messy-incr-rule * good naming * activated strict syntax check with OPA native * added syntax check to CI, updated linter config * moved config to root * directory match package structure rule * renamed contains operator * removed unused imports * readme update * format readme * typo * add a test section to readme * fixed comment in regal config * renamed makefile * correct config argument * enabled camelCase in tests and for variables and packages * corrected usageof armory.testData * renamed buildIntent.. to intentTo * ignore build files * improved comments in regal config
- Loading branch information
Showing
143 changed files
with
2,708 additions
and
2,283 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,72 @@ | ||
ignore: | ||
# Ignore userOperation files as functionality is not certain yet. | ||
# Ignore dist and rego-build directories as they don't need linting. | ||
files: | ||
- '*userOperation*' | ||
- 'dist/**' | ||
- 'rego-build/**' | ||
rules: | ||
style: | ||
# This rule is disabled in tests to let us paste in big JSON payloads without having to worry about line length. | ||
rule-length: | ||
level: error | ||
ignore: | ||
files: | ||
- '*_test.rego' | ||
line-length: | ||
level: error | ||
ignore: | ||
files: | ||
- '*_test.rego' | ||
# Signal TODO comments to the PR reviewer | ||
todo-comment: | ||
level: warning | ||
# We use camel case to comply with our naming conventions | ||
prefer-snake-case: | ||
level: ignore | ||
# In the future, it can be beneficial to re-activate this rule to ensure one source of truth for data and input shape. | ||
# It is already done for "data" part, through 'armory.entities' package. "input" is still accessed on the fly when needed. | ||
# If we do so, then we can ignore this rule only in querying packages. | ||
external-reference: | ||
level: ignore | ||
custom: | ||
naming-convention: | ||
level: error | ||
ignore: | ||
# Ignore the naming convention for 'policy' files - Our policy definition can't be camelCased: permit[{...}]. | ||
files: | ||
- '*_policies*.rego' | ||
conventions: | ||
# We use camelCase to comply with our monorepo naming conventions | ||
# OPA test runner requires test rules to start with "test_", which is not camelCase. | ||
# Regal naming conventions applies to all files, we can't subset them by file groups | ||
# So we tolerate both standards in the same naming convetion, only for 'rules'. | ||
- pattern: '^(test_)?[a-z]+([A-Z][a-z0-9]+)*$' | ||
targets: | ||
- rule | ||
description: 'Use camelCase or test_camelCase for rules' | ||
- pattern: '^[a-z]+([A-Z][a-z0-9]+)*$' | ||
targets: | ||
- function | ||
description: 'Use camelCase for all functions' | ||
- pattern: ^([a-z][a-z0-9]*([A-Z][a-z0-9]+)*|\$\d+)$ | ||
targets: | ||
- variable | ||
description: 'Use camelCase for variables or "$number" for unused variables' | ||
- pattern: '^[a-z]+([A-Z][a-z0-9]+)*(\.[a-z]+([A-Z][a-z0-9]+)*)*$' | ||
targets: | ||
- package | ||
description: 'Use camelCase.camelCase... for packages' | ||
# Future improvement: remove ignore for test files. | ||
# It would be better to strictly split test and production code in different packages to make sure test code is never hit by production one | ||
idiomatic: | ||
directory-package-mismatch: | ||
level: error | ||
ignore: | ||
files: | ||
- '*_test.rego' | ||
# Disabling this rule allows to call tested function from the test file without importing functionality package. | ||
# Related to comment above, this ignore can be removed if we split test and production code in different packages. | ||
testing: | ||
test-outside-test-package: | ||
level: ignore |
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
44 changes: 44 additions & 0 deletions
44
apps/policy-engine/src/resource/open-policy-agent/rego/README.md
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,44 @@ | ||
# Packages | ||
|
||
## Main | ||
|
||
The implementation of engine general logic. This package is the one were transpiled policy are written | ||
Transpiled policies then use Armory/criteria functions to evaluate input | ||
|
||
## Armory | ||
|
||
### Constants | ||
|
||
This package contains all constants that are used by production code | ||
|
||
### Criteria | ||
|
||
Criteria contains the function that build the logic for every transpiled policy. | ||
**This package should have exactly the same number of files as we have supported criteria** | ||
|
||
### Feeds | ||
|
||
Criteria that needs to access our feeds should be depending from this package | ||
|
||
### Entities | ||
|
||
Functions used to query loaded data. It serves as a source of truth to know if something is in data.entities. | ||
|
||
- Enforce invariants like lowercasing hex addresses | ||
- Aggregate data from multiple places in entity in order to build useful relationships | ||
- build runtime types that depends on entity data result | ||
|
||
### Lib | ||
|
||
Utils that are not domain specific, like case insensitive comparison or time. | ||
|
||
### Test_Data | ||
|
||
Values that are specifically used by tests. | ||
**this shouldn't be imported in production code** | ||
|
||
# Tests | ||
|
||
Currently tests are not separated in different package. Future improvement should be to strictly separate test and production code | ||
By moving tests in separate packages. | ||
We can enforce it by re-enabling `test-outside-test-package` rule in `.regal/config.yaml` |
32 changes: 0 additions & 32 deletions
32
...licy-engine/src/resource/open-policy-agent/rego/__test__/criteria/intent/amount_test.rego
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...cy-engine/src/resource/open-policy-agent/rego/__test__/criteria/intent/assigned_test.rego
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...licy-engine/src/resource/open-policy-agent/rego/__test__/criteria/intent/permit_test.rego
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
...licy-engine/src/resource/open-policy-agent/rego/__test__/criteria/intent/source_test.rego
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
apps/policy-engine/src/resource/open-policy-agent/rego/__test__/criteria/principal_test.rego
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.