-
Notifications
You must be signed in to change notification settings - Fork 58
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
Towards better inference: bits → nibbles #3808
base: main
Are you sure you want to change the base?
Conversation
…coordination into set-default-risk-in-model
…coordination into set-default-risk-in-model
…uler from recreating already deleted oois trhough affirmations
…cheduler_from_reacreating_already_deleted_oois_through_affirmations' into feature/nibbles
This reverts commit 1b4aed6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I've provided mostly Python related feedback since I missed the discussion about Nibbles. I'd love to know more about it, why is it better than bits, and what are the main differences? Perhaps we can meet offline for coffee soon?
return hash(str(self.ooi_type) + self.relation_path if self.relation_path else "\0") | ||
|
||
|
||
class NibbleDefinition: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering, what is the reason this isn't implemented as an e.g. Pydantic class but instead as a POJO-like class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow the Pydantic class does not work well with the importlib yielding the payload... not sure why but it fixed the issues so I moved on -- perhaps hoping one day you would fix it ;)
General flowThe Nibbles "flow" Is as follows. Some ideas are explained below. graph TD
A[Start] --> Z[Object is newly created]
Z --> Y[Add object to stack]
A --> X[Object is updated]
Y --> C[For all objects on the stack]
X --> Y
X -.-> H[Perform Dollar Sign Magic]
C --> D[Check which Nibbles have the object's type in their signature]
D --> E[For all Nibbles with matching type]
E -->|Query attribute present?| F{Query Attribute?}
F -->|No| O[Nibble requires only one OOI]
O --> G[Run Nibble]
F -->|Yes| H[Perform Dollar Sign Magic]
H --> I[Run the query]
I --> J[Output in Octopoes JSON format]
J --> K[Use Jamespath JSON parser for all types in nibble signature]
K --> L[Cross-product of all outputs]
L --> G
G --> M[Output objects go back to the stack]
M --> Y
Jmespath queriesJmespath allows for easy parsing of the Octopoes JSON output. From the Octopoes output, a Jmespath query will be run for all elements of the signature to get the input for the Nibble. A Jmespath can be ExampleLet's say we want to create a Nibble that checks whether the
The Octopoes query can be (we still need to add that this query checks specifically for the OOI that is added/changed): {
:query {
:find [(pull ?var [*])]
:where [
(or
(and [?var :object_type "URL" ] [?var :URL/primary_key $2 ])
(and [?var :object_type "Network" ] [?var :Network/primary_key $1])
)
]
}
} After this the product of all results from this query will be created (note that there is either one URL and multiple Networks or one Network and multiple URLs). When we have the product, the nibble can be run: def find_network_url(network: Network, url: URL) -> Iterator[OOI]:
if len(network.name) == len(str(url.raw)):
yield Finding(
finding_type=KATFindingType(id="Network and URL have same name length").reference,
ooi=network.reference,
proof=url.reference,
) |
We need a fast, insecure, deterministic hashing algorithm: I am proposing xxhash by zip-hero Yann Collett (so actually python-xxhash); let us discuss! |
Quality Gate failedFailed conditions |
Changes
Bits → Nibbles
Issue link
N/A
Demo
T.B.D.
QA notes
T.B.D.
Code Checklist
.env
changes files if required and changed the.env-dist
accordingly.Checklist for code reviewers:
Copy-paste the checklist from the docs/source/templates folder into your comment.
Checklist for QA:
Copy-paste the checklist from the docs/source/templates folder into your comment.