Skip to content
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

[feature] gRPC #380

Merged
merged 24 commits into from
Nov 18, 2023
Merged

[feature] gRPC #380

merged 24 commits into from
Nov 18, 2023

Conversation

KCarretto
Copy link
Collaborator

What type of PR is this?

/kind feature

What this PR does / why we need it:

Changes:

  • Refactor tavern http and Auth code
  • Define a c2.proto spec for agent communication
  • Implement a http/2 gRPC server hosted on the same server as the tavern GraphQL api
  • Generate Rust gRPC client code and update imix to use it as the primary mechanism for callbacks

What’s left:

Which issue(s) this PR fixes:

Fixes #331

implants/Cargo.toml Show resolved Hide resolved
implants/imix/src/main.rs Show resolved Hide resolved
implants/lib/c2/Cargo.toml Outdated Show resolved Hide resolved
implants/lib/c2/Cargo.toml Outdated Show resolved Hide resolved
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

[build-dependencies]
tonic-build = "0.10"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move this to the parent workspace.
If other parts of realm use it in the future would be nice to continue our standard of using one version of a dep across the project.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

idk how to add build dependencies there, no existing section for them

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be able to add:

[workspace.build-dependencies]
tonic-build = "0.10"

to between dependencies and profile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doesn't work like that, would require us to add it to the workspace dependencies:


Caused by:
  failed to load manifest for dependency `c2`

Caused by:
  failed to parse manifest at `/workspaces/realm/implants/lib/c2/Cargo.toml`

Caused by:
  error inheriting `tonic-build` from workspace root manifest's `workspace.dependencies.tonic-build`

Caused by:
  `dependency.tonic-build` was not found in `workspace.dependencies`

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added them to the workspace dependencies I guess /shrug

implants/lib/eldritch/src/lib.rs Show resolved Hide resolved
tavern/app.go Outdated Show resolved Hide resolved
tavern/app.go Show resolved Hide resolved
tavern/app.go Show resolved Hide resolved
tavern/internal/c2/generate.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 18, 2023

Codecov Report

Attention: 485 lines in your changes are missing coverage. Please review.

Comparison is base (6cd9f5e) 75.35% compared to head (e4570d1) 68.49%.

Files Patch % Lines
implants/imix/src/main.rs 0.87% 227 Missing ⚠️
implants/lib/c2/src/c2.rs 0.00% 130 Missing ⚠️
tavern/internal/c2/server.go 42.03% 82 Missing and 9 partials ⚠️
implants/lib/eldritch/src/lib.rs 86.44% 16 Missing ⚠️
tavern/app.go 71.92% 13 Missing and 3 partials ⚠️
tavern/internal/c2/rollback.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #380      +/-   ##
==========================================
- Coverage   75.35%   68.49%   -6.87%     
==========================================
  Files         107      106       -1     
  Lines        7255     7122     -133     
==========================================
- Hits         5467     4878     -589     
- Misses       1690     2136     +446     
- Partials       98      108      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

implants/imix/src/main.rs Outdated Show resolved Hide resolved
implants/imix/src/main.rs Outdated Show resolved Hide resolved
implants/imix/src/main.rs Outdated Show resolved Hide resolved
implants/lib/c2/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

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

Second look over couple more comments.

@KCarretto KCarretto merged commit 0bbd7ca into main Nov 18, 2023
6 checks passed
@KCarretto KCarretto deleted the grpc branch November 18, 2023 05:03
KCarretto added a commit that referenced this pull request Feb 1, 2024
 
[feature] gRPC (#380)

* refactoring endpoints

* refactor http setup

* Updated release.sh to set Tavern version

* began implementing server

* some more implementation

* fix issues, add testing

* Working on rust client

* it might work ¯\_(ツ)_/¯

* it works, but im not happy about it

* some cleanup, fix agent crash if no connection available

* attempt to fix some codegen

* log warning if protos aren't compiled

* Fix build.rs

* enable http2

* Use name as task.id

* disable debug mode for imix:

* rm dead code

* remove dead code, update which version

* Add some gRPC docs

* move build dependencies to workspace dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrating the agent from JSON graphql to gRPC
2 participants