-
Notifications
You must be signed in to change notification settings - Fork 8
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
Improved developer documentation with flowcharts #546
Changes from 2 commits
2b575be
069db52
8499cfd
2903ac7
5627824
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
--- | ||
title: Flowchart for requesting another plugin | ||
--- | ||
```mermaid | ||
flowchart LR | ||
|
||
subgraph Z["SDK"] | ||
direction TB | ||
start--query's() parameters are the input value and target plugin/query endpoint from the starting plugin's query trait's run() function.--> | ||
query --The target plugin/query endpoint is converted from the generic T to a QueryTarget. The input is converted to a JSON value with an InvalidJSONInQuery Key error if not properly converted. The variables are named query_target and input. From there query's inner function, query_inner() is called with the query_target and input as parameters--> query_inner-- During normal execution, when the engine is not a mock engine, the query() function creates a QueryTarget object and calls the send() function. The Query object is the send() function's parameter.-->send | ||
end | ||
|
||
subgraph ZA["Hipcheck Core"] | ||
direction TB | ||
hipcheck_proto --Opens an rpc protocol so Hipcheck can request queries to the plugin and the plugins may issue queries to other plugins-->finishHipcheck | ||
end | ||
Comment on lines
+15
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not relevant to this particular graph, we're discussing what happens once the gRPC channel is already open. Also, if this were in the graph it would happen before the |
||
|
||
subgraph ZB["SDK"] | ||
direction TB | ||
recv--creates a variable called msg_chunks that will get the result from recv_raw.-->recv_raw --returns a queue of messages returned from send function if the grpc channel is still open as a vector -->recv --reads the messages from recv_raw --> finishSDK | ||
end | ||
|
||
Z-- The send function sends a grpc query from the plugin to the hipcheck server. The query parameter is given the RPC type InitiateQueryProtocolResponse-->ZA --Control transfers back to SDK-->ZB | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The specific type |
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: Plugins101 | ||
--- | ||
# Plugins 101 | ||
## The purpose of this document is to provide a brief overview of plugins. More detailed information can be found in the for-developers.md document. | ||
## The author has attempted to synthezise the information about queries found from the developer and user documentation into a brief summary. This may be helpful to read before or after reading the more detailed documentation to better understand plugins and how the work. | ||
- Plugins allow users to query data sources | ||
- Plugins can get information from other plugins | ||
- Plugins must have a CLI that accepts a port argument. The port indicates where the plugin is listening. | ||
- Plugins can support multiple queries. | ||
- Query endpoints are the functions that implement those queries | ||
- Top-level analysis plugins should have a default query endpoint that accepts a struct Target | ||
- The struct Target encompasses all the relevant info of a repository that we want to analyze. The struct is generally a local repo or github URL or package id. | ||
- Every query endpoint must have a struct that implements the Query trait. You can also use the macro called 'query' to mark functions you've written as query endpoints | ||
- The Query trait has the input, output, and actual query logic. The actual query logic is contained in the run() function. The run() function takes a mutable plugin engine as a parameter | ||
- A plugin engine is a struct that allows you to request information from other plugins. | ||
- The input and output schema for the Query trait are in a json file format. Plugins return data/measurements on data as a json. | ||
- Policy expressions determine whether the analysis from the plugins passes or fails. | ||
- You can provide plugins with a set of parameters to configure the plugins behaviors | ||
- In addition to query structs, plugins contain a Plugin trait: | ||
- The functions/strings within the Plugin trait are: | ||
- Strings: | ||
- PUBLISHER: defines the publisher | ||
- NAME: defines the name | ||
- Functions: | ||
- set_config(): allows you to configure the plugin, parameter is a set of 'String' key-value pairs | ||
- queries(): binds all of your query structs (structs that implement the Query trait) to the plugin. Instantiates each struct and creates a NamedQuery instance with a name in the name field. The query name must be designated as a struct instead of a string. | ||
- explain_default_query(): explains the default query | ||
- default_polict_expression(): returns the default policy expression for your default query endpoint | ||
- The PluginServer actually runs the plugin | ||
- In short plugins contain query endpoints. Query endpoints must either A) implement the Query trait or B) mark a function as a query endpoint. In addition to query endpoints, plugins also contain a Plugin trait. Once you finish defining your plugin, you pass the plugin instance and port to the PluginServer. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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.
We don't need to describe the error paths, particularly to do with JSON deserialization.