Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Derive conflict resolution #561

Merged
merged 161 commits into from
Mar 4, 2021
Merged

Derive conflict resolution #561

merged 161 commits into from
Mar 4, 2021

Conversation

colin-grapl
Copy link
Contributor

@colin-grapl colin-grapl commented Jan 25, 2021

Which issue does this PR correspond to?

#147
#148

What changes does this PR make to Grapl? Why?

  1. Removes the underlying protobuf schemas for node types such as 'Process' and 'File', and instead leverages three distinct schemas - NodeDescription, IdentifiedNode, MergedNode.

  2. Replaces 'string', 'int', and 'uint' with conflict resolvable types. The logic to enforce that resolution does not exist and will be implemented in a separate (and much smaller!) PR.

Specifically, while this diff appears very large, there are really just three places you need to worry about:

  1. src/rust/derive-dynamic-node/src/lib.rs
    This is where the conflict resolution macro changes occur, allowing us to specify the resolution mechanism for a property.

  2. src/proto/graplinc/grapl/api/graph/v1beta1/types.proto
    This is where the new proto structures are defined. The major changes are that we now have distinct node/graph types based on the state of the processed data (described, identified, merged) and, on top of that, the protobuf types to express the conflict resolution.

I've also documented most of the protobuf.

  1. src/rust/graph-descriptions/src/lib.rs
    This is where the impl of these new protobuf types exist. The previously defined File, Process, etc are now in the endpoint-plugin.

All other changes are just to support this - there's a lot of diff noise involved, such as deleting tons of files that are no longer necessary, because the logic for nodes is now condensed.

The other churn is in the graph-merger, where I've spent some time refactoring the upsert logic, separating structures out into their own files. I've also added integration tests - 414 lines of additional integration tests are now in the graph-merger, as well as code to support those tests.

If you look at the git stats you'll find that while 104 files have been touched, the vast majority of those are just changing things like Graph::new(0) to GraphDescription;:new(), or that sort of thing. Also, apparently there have been some formatting changes, so that caused churn as well :(

How were these changes tested?

I've tested locally and I've added lots of integration tests.

@lgtm-com
Copy link

lgtm-com bot commented Mar 2, 2021

This pull request introduces 2 alerts and fixes 2 when merging b2f85ab into a045aff - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

fixed alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

Copy link
Contributor

@d0nut-grapl d0nut-grapl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems mostly the same from when we went over it (loving the new tests you added in btw).

I'd love for another pair of eyes to go over this btw just because it's so huge and I'm biased (saw once before :P )

@@ -82,7 +77,6 @@ pub fn generate_process_create_subgraph(
);

graph.add_edge("children", parent.clone_node_key(), child.clone_node_key());
graph.add_edge("parent", child.clone_node_key(), parent.clone_node_key());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colin-grapl is there a reason this was deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's redundant - there's no need to specify an edge and a reverse edge, one implies the other, and that's handled downstream.

@lgtm-com
Copy link

lgtm-com bot commented Mar 3, 2021

This pull request introduces 2 alerts and fixes 2 when merging c65a449 into ce9016f - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

fixed alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

Copy link
Contributor

@christophermaier christophermaier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments... still not as familiar with this code as I feel I would need to be to be more constructive.

match attr {
IMMUTABLE => resolution = Some(attr.to_string()),
INCREMENT => resolution = Some(attr.to_string()),
DECREMENT => resolution = Some(attr.to_string()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably just use one match arm on IMMUTABLE | INCREMENT | DECREMENT.

src/rust/derive-dynamic-node/src/lib.rs Outdated Show resolved Hide resolved
src/rust/derive-dynamic-node/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@inickles-grapl inickles-grapl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have questions on a couple items.

src/rust/Dockerfile Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
src/rust/endpoint-plugin/src/graph.rs Outdated Show resolved Hide resolved
src/rust/endpoint-plugin/src/lib.rs Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Mar 3, 2021

This pull request introduces 2 alerts and fixes 2 when merging 830b556 into eb80c50 - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

fixed alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Mar 3, 2021

This pull request introduces 1 alert and fixes 2 when merging 07501c4 into a47b9e9 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

fixed alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Mar 4, 2021

This pull request introduces 1 alert and fixes 2 when merging 85439f0 into a47b9e9 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

fixed alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

@lgtm-com
Copy link

lgtm-com bot commented Mar 4, 2021

This pull request introduces 1 alert and fixes 2 when merging 7e9891f into a47b9e9 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

fixed alerts:

  • 1 for Unused import
  • 1 for Unused variable, import, function or class

@colin-grapl colin-grapl merged commit 3608268 into staging Mar 4, 2021
@colin-grapl colin-grapl deleted the DeriveConflictResolution branch March 4, 2021 02:02
christophermaier added a commit that referenced this pull request Mar 4, 2021
The `Edge#edgeName` field was renamed in #561 so we no longer need to
ignore any lints.

See grapl-security/issue-tracker#237

Signed-off-by: Christopher Maier <chris@graplsecurity.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants