diff --git a/implants/lib/eldritch/src/lib.rs b/implants/lib/eldritch/src/lib.rs index dd58527ce..f46295115 100644 --- a/implants/lib/eldritch/src/lib.rs +++ b/implants/lib/eldritch/src/lib.rs @@ -3,6 +3,7 @@ pub mod crypto; pub mod file; pub mod pivot; pub mod process; +mod report; mod runtime; pub mod sys; pub mod time; diff --git a/implants/lib/eldritch/src/report/mod.rs b/implants/lib/eldritch/src/report/mod.rs new file mode 100644 index 000000000..1e3ff24f7 --- /dev/null +++ b/implants/lib/eldritch/src/report/mod.rs @@ -0,0 +1,128 @@ +mod process_list_impl; + +use allocative::Allocative; +use derive_more::Display; +use serde::{Serialize, Serializer}; +use starlark::collections::SmallMap; +use starlark::environment::{Methods, MethodsBuilder, MethodsStatic}; +use starlark::eval::Evaluator; +use starlark::values::none::NoneType; +use starlark::values::{ + starlark_value, ProvidesStaticType, StarlarkValue, UnpackValue, Value, ValueLike, +}; +use starlark::{starlark_module, starlark_simple_value}; + +#[derive(Copy, Clone, Debug, PartialEq, Display, ProvidesStaticType, Allocative)] +#[display(fmt = "ReportLibrary")] +pub struct ReportLibrary(); +starlark_simple_value!(ReportLibrary); + +#[allow(non_upper_case_globals)] +#[starlark_value(type = "report_library")] +impl<'v> StarlarkValue<'v> for ReportLibrary { + fn get_methods() -> Option<&'static Methods> { + static RES: MethodsStatic = MethodsStatic::new(); + RES.methods(methods) + } +} + +impl Serialize for ReportLibrary { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'v> UnpackValue<'v> for ReportLibrary { + fn expected() -> String { + ReportLibrary::get_type_value_static().as_str().to_owned() + } + + fn unpack_value(value: Value<'v>) -> Option { + Some(*value.downcast_ref::().unwrap()) + } +} + +// This is where all of the "report.X" impl methods are bound +#[starlark_module] +#[rustfmt::skip] +#[allow(clippy::needless_lifetimes, clippy::type_complexity, clippy::too_many_arguments)] +fn methods(builder: &mut MethodsBuilder) { + fn process_list(this: ReportLibrary, starlark_eval: &mut Evaluator<'v, '_>, process_list: Vec>) -> anyhow::Result { + if false { println!("Ignore unused this var. _this isn't allowed by starlark. {:?}", this); } + process_list_impl::process_list(starlark_eval, process_list)?; + Ok(NoneType{}) + } +} + +#[cfg(test)] +mod test { + use std::collections::HashMap; + + use crate::pb::process::Status; + use crate::pb::{Process, ProcessList, Tome}; + use crate::Runtime; + use anyhow::Error; + + macro_rules! process_list_tests { + ($($name:ident: $value:expr,)*) => { + $( + #[tokio::test] + async fn $name() { + let tc: TestCase = $value; + let (runtime, broker) = Runtime::new(); + let handle = tokio::task::spawn_blocking(move || { + runtime.run(tc.tome); + }); + + let want_err_str = match tc.want_error { + Some(err) => err.to_string(), + None => "".to_string(), + }; + let err_str = match broker.collect_errors().pop() { + Some(err) => err.to_string(), + None => "".to_string(), + }; + assert_eq!(want_err_str, err_str); + assert_eq!(tc.want_output, broker.collect_text().join("")); + assert_eq!(Some(tc.want_proc_list), broker.collect_process_lists().pop()); + handle.await.unwrap(); + } + )* + } + } + + struct TestCase { + pub tome: Tome, + pub want_output: String, + pub want_error: Option, + pub want_proc_list: ProcessList, + } + + process_list_tests! { + one_process: TestCase{ + tome: Tome{ + eldritch: String::from(r#"report.process_list([{"pid":5,"ppid":101,"name":"test","username":"root","path":"/bin/cat","env":"COOL=1","command":"cat","cwd":"/home/meow","status":"IDLE"}])"#), + parameters: HashMap::new(), + file_names: Vec::new(), + }, + want_proc_list: ProcessList{list: vec![ + Process{ + pid: 5, + ppid: 101, + name: "test".to_string(), + principal: "root".to_string(), + path: "/bin/cat".to_string(), + env: "COOL=1".to_string(), + cmd: "cat".to_string(), + cwd: "/home/meow".to_string(), + status: Status::Idle.into(), + }, + ]}, + want_output: String::from(""), + want_error: None, + }, + } +} diff --git a/implants/lib/eldritch/src/report/process_list_impl.rs b/implants/lib/eldritch/src/report/process_list_impl.rs new file mode 100644 index 000000000..52e83fa0b --- /dev/null +++ b/implants/lib/eldritch/src/report/process_list_impl.rs @@ -0,0 +1,56 @@ +use anyhow::Result; +use starlark::values::Value; +use starlark::{collections::SmallMap, eval::Evaluator}; + +use crate::{ + pb::{process::Status, Process, ProcessList}, + runtime::Client, +}; + +pub fn process_list( + starlark_eval: &Evaluator<'_, '_>, + process_list: Vec>, +) -> Result<()> { + let client = Client::from_extra(starlark_eval.extra)?; + + let mut pb_process_list = ProcessList { list: Vec::new() }; + for proc in process_list { + pb_process_list.list.push(Process { + pid: unpack_u64(&proc, "pid"), + ppid: unpack_u64(&proc, "ppid"), + name: unpack_string(&proc, "name"), + principal: unpack_string(&proc, "username"), + path: unpack_string(&proc, "path"), + cmd: unpack_string(&proc, "command"), + env: unpack_string(&proc, "env"), + cwd: unpack_string(&proc, "cwd"), + status: unpack_status(&proc).into(), + }) + } + + client.report_process_list(pb_process_list)?; + Ok(()) +} + +fn unpack_i32(proc: &SmallMap, key: &str) -> i32 { + match proc.get(key) { + Some(val) => val.unpack_i32().unwrap_or(0), + None => 0, + } +} +fn unpack_u64(proc: &SmallMap, key: &str) -> u64 { + unpack_i32(proc, key) as u64 +} + +fn unpack_string(proc: &SmallMap, key: &str) -> String { + match proc.get(key) { + Some(v) => v.unpack_str().unwrap_or("").to_string(), + None => String::from(""), + } +} + +fn unpack_status(proc: &SmallMap) -> Status { + let val = unpack_string(proc, "status"); + let status_str = format!("STATUS_{}", val).to_uppercase(); + Status::from_str_name(status_str.as_str()).unwrap_or(Status::Unknown) +} diff --git a/implants/lib/eldritch/src/runtime/exec.rs b/implants/lib/eldritch/src/runtime/exec.rs index eec0b9113..f4513c1b3 100644 --- a/implants/lib/eldritch/src/runtime/exec.rs +++ b/implants/lib/eldritch/src/runtime/exec.rs @@ -2,7 +2,7 @@ use super::{Broker, Client, FileRequest}; use crate::pb::{File, ProcessList}; use crate::{ assets::AssetsLibrary, crypto::CryptoLibrary, file::FileLibrary, pb::Tome, pivot::PivotLibrary, - process::ProcessLibrary, sys::SysLibrary, time::TimeLibrary, + process::ProcessLibrary, report::ReportLibrary, sys::SysLibrary, time::TimeLibrary, }; use anyhow::{Error, Result}; use chrono::Utc; @@ -138,6 +138,7 @@ impl Runtime { const assets: AssetsLibrary = AssetsLibrary(); const crypto: CryptoLibrary = CryptoLibrary(); const time: TimeLibrary = TimeLibrary(); + const report: ReportLibrary = ReportLibrary(); } GlobalsBuilder::extended_by(&[ diff --git a/tavern/internal/ent/schema/host_process.go b/tavern/internal/ent/schema/host_process.go index d784cd873..5568d85e4 100644 --- a/tavern/internal/ent/schema/host_process.go +++ b/tavern/internal/ent/schema/host_process.go @@ -19,11 +19,13 @@ func (HostProcess) Fields() []ent.Field { return []ent.Field{ field.Uint64("pid"). Annotations( + entgql.Type("Uint64"), entgql.OrderField("PROCESS_ID"), ). Comment("ID of the process."), field.Uint64("ppid"). Annotations( + entgql.Type("Uint64"), entgql.OrderField("PARENT_PROCESS_ID"), ). Comment("ID of the parent process."), diff --git a/tavern/internal/graphql/ent.resolvers.go b/tavern/internal/graphql/ent.resolvers.go index e1cbf5826..c66e1e8b4 100644 --- a/tavern/internal/graphql/ent.resolvers.go +++ b/tavern/internal/graphql/ent.resolvers.go @@ -12,16 +12,6 @@ import ( "realm.pub/tavern/internal/graphql/generated" ) -// Pid is the resolver for the pid field. -func (r *hostProcessResolver) Pid(ctx context.Context, obj *ent.HostProcess) (int, error) { - panic(fmt.Errorf("not implemented: Pid - pid")) -} - -// Ppid is the resolver for the ppid field. -func (r *hostProcessResolver) Ppid(ctx context.Context, obj *ent.HostProcess) (int, error) { - panic(fmt.Errorf("not implemented: Ppid - ppid")) -} - // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) { panic(fmt.Errorf("not implemented: Node - node")) @@ -32,97 +22,7 @@ func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, erro panic(fmt.Errorf("not implemented: Nodes - nodes")) } -// Pid is the resolver for the pid field. -func (r *hostProcessWhereInputResolver) Pid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: Pid - pid")) -} - -// PidNeq is the resolver for the pidNEQ field. -func (r *hostProcessWhereInputResolver) PidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PidNeq - pidNEQ")) -} - -// PidIn is the resolver for the pidIn field. -func (r *hostProcessWhereInputResolver) PidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { - panic(fmt.Errorf("not implemented: PidIn - pidIn")) -} - -// PidNotIn is the resolver for the pidNotIn field. -func (r *hostProcessWhereInputResolver) PidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { - panic(fmt.Errorf("not implemented: PidNotIn - pidNotIn")) -} - -// PidGt is the resolver for the pidGT field. -func (r *hostProcessWhereInputResolver) PidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PidGt - pidGT")) -} - -// PidGte is the resolver for the pidGTE field. -func (r *hostProcessWhereInputResolver) PidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PidGte - pidGTE")) -} - -// PidLt is the resolver for the pidLT field. -func (r *hostProcessWhereInputResolver) PidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PidLt - pidLT")) -} - -// PidLte is the resolver for the pidLTE field. -func (r *hostProcessWhereInputResolver) PidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PidLte - pidLTE")) -} - -// Ppid is the resolver for the ppid field. -func (r *hostProcessWhereInputResolver) Ppid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: Ppid - ppid")) -} - -// PpidNeq is the resolver for the ppidNEQ field. -func (r *hostProcessWhereInputResolver) PpidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PpidNeq - ppidNEQ")) -} - -// PpidIn is the resolver for the ppidIn field. -func (r *hostProcessWhereInputResolver) PpidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { - panic(fmt.Errorf("not implemented: PpidIn - ppidIn")) -} - -// PpidNotIn is the resolver for the ppidNotIn field. -func (r *hostProcessWhereInputResolver) PpidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { - panic(fmt.Errorf("not implemented: PpidNotIn - ppidNotIn")) -} - -// PpidGt is the resolver for the ppidGT field. -func (r *hostProcessWhereInputResolver) PpidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PpidGt - ppidGT")) -} - -// PpidGte is the resolver for the ppidGTE field. -func (r *hostProcessWhereInputResolver) PpidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PpidGte - ppidGTE")) -} - -// PpidLt is the resolver for the ppidLT field. -func (r *hostProcessWhereInputResolver) PpidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PpidLt - ppidLT")) -} - -// PpidLte is the resolver for the ppidLTE field. -func (r *hostProcessWhereInputResolver) PpidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { - panic(fmt.Errorf("not implemented: PpidLte - ppidLTE")) -} - -// HostProcess returns generated.HostProcessResolver implementation. -func (r *Resolver) HostProcess() generated.HostProcessResolver { return &hostProcessResolver{r} } - // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } -// HostProcessWhereInput returns generated.HostProcessWhereInputResolver implementation. -func (r *Resolver) HostProcessWhereInput() generated.HostProcessWhereInputResolver { - return &hostProcessWhereInputResolver{r} -} - -type hostProcessResolver struct{ *Resolver } type queryResolver struct{ *Resolver } -type hostProcessWhereInputResolver struct{ *Resolver } diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index 7c96ffb74..d2158e9f0 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -24,10 +24,6 @@ import ( // region ************************** generated!.gotpl ************************** -type HostProcessResolver interface { - Pid(ctx context.Context, obj *ent.HostProcess) (int, error) - Ppid(ctx context.Context, obj *ent.HostProcess) (int, error) -} type QueryResolver interface { Node(ctx context.Context, id int) (ent.Noder, error) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) @@ -42,25 +38,6 @@ type QueryResolver interface { Me(ctx context.Context) (*ent.User, error) } -type HostProcessWhereInputResolver interface { - Pid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error - PidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error - PidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - Ppid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PpidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PpidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error - PpidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error - PpidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PpidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PpidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error - PpidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** @@ -2404,7 +2381,7 @@ func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.HostProcess().Pid(rctx, obj) + return obj.Pid, nil }) if err != nil { ec.Error(ctx, err) @@ -2416,19 +2393,19 @@ func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uint64) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNUint642uint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_HostProcess_pid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil @@ -2448,7 +2425,7 @@ func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.HostProcess().Ppid(rctx, obj) + return obj.Ppid, nil }) if err != nil { ec.Error(ctx, err) @@ -2460,19 +2437,19 @@ func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uint64) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNUint642uint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_HostProcess_ppid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Uint64 does not have child fields") }, } return fc, nil @@ -9825,178 +9802,146 @@ func (ec *executionContext) unmarshalInputHostProcessWhereInput(ctx context.Cont var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pid")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().Pid(ctx, &it, data); err != nil { - return it, err - } + it.Pid = data case "pidNEQ": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PidNeq(ctx, &it, data); err != nil { - return it, err - } + it.PidNEQ = data case "pidIn": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PidIn(ctx, &it, data); err != nil { - return it, err - } + it.PidIn = data case "pidNotIn": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PidNotIn(ctx, &it, data); err != nil { - return it, err - } + it.PidNotIn = data case "pidGT": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PidGt(ctx, &it, data); err != nil { - return it, err - } + it.PidGT = data case "pidGTE": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PidGte(ctx, &it, data); err != nil { - return it, err - } + it.PidGTE = data case "pidLT": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PidLt(ctx, &it, data); err != nil { - return it, err - } + it.PidLT = data case "pidLTE": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PidLte(ctx, &it, data); err != nil { - return it, err - } + it.PidLTE = data case "ppid": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppid")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().Ppid(ctx, &it, data); err != nil { - return it, err - } + it.Ppid = data case "ppidNEQ": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PpidNeq(ctx, &it, data); err != nil { - return it, err - } + it.PpidNEQ = data case "ppidIn": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PpidIn(ctx, &it, data); err != nil { - return it, err - } + it.PpidIn = data case "ppidNotIn": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PpidNotIn(ctx, &it, data); err != nil { - return it, err - } + it.PpidNotIn = data case "ppidGT": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PpidGt(ctx, &it, data); err != nil { - return it, err - } + it.PpidGT = data case "ppidGTE": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PpidGte(ctx, &it, data); err != nil { - return it, err - } + it.PpidGTE = data case "ppidLT": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PpidLt(ctx, &it, data); err != nil { - return it, err - } + it.PpidLT = data case "ppidLTE": var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.HostProcessWhereInput().PpidLte(ctx, &it, data); err != nil { - return it, err - } + it.PpidLTE = data case "name": var err error @@ -16202,77 +16147,15 @@ func (ec *executionContext) _HostProcess(ctx context.Context, sel ast.SelectionS atomic.AddUint32(&out.Invalids, 1) } case "pid": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._HostProcess_pid(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out.Values[i] = ec._HostProcess_pid(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "ppid": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._HostProcess_ppid(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue + out.Values[i] = ec._HostProcess_ppid(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "name": out.Values[i] = ec._HostProcess_name(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index 2980e428d..ed29299e6 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -35,10 +35,8 @@ type Config struct { } type ResolverRoot interface { - HostProcess() HostProcessResolver Mutation() MutationResolver Query() QueryResolver - HostProcessWhereInput() HostProcessWhereInputResolver } type DirectiveRoot struct { @@ -1904,9 +1902,9 @@ type HostProcess implements Node { """Timestamp of when this ent was last updated""" lastModifiedAt: Time! """ID of the process.""" - pid: Int! + pid: Uint64! """ID of the parent process.""" - ppid: Int! + ppid: Uint64! """The name of the process.""" name: String! """The user the process is running as.""" @@ -1994,23 +1992,23 @@ input HostProcessWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int + pid: Uint64 + pidNEQ: Uint64 + pidIn: [Uint64!] + pidNotIn: [Uint64!] + pidGT: Uint64 + pidGTE: Uint64 + pidLT: Uint64 + pidLTE: Uint64 """ppid field predicates""" - ppid: Int - ppidNEQ: Int - ppidIn: [Int!] - ppidNotIn: [Int!] - ppidGT: Int - ppidGTE: Int - ppidLT: Int - ppidLTE: Int + ppid: Uint64 + ppidNEQ: Uint64 + ppidIn: [Uint64!] + ppidNotIn: [Uint64!] + ppidGT: Uint64 + ppidGTE: Uint64 + ppidLT: Uint64 + ppidLTE: Uint64 """name field predicates""" name: String nameNEQ: String diff --git a/tavern/internal/graphql/gqlgen.yml b/tavern/internal/graphql/gqlgen.yml index e7faf746d..4d4eb5a60 100644 --- a/tavern/internal/graphql/gqlgen.yml +++ b/tavern/internal/graphql/gqlgen.yml @@ -25,15 +25,6 @@ resolver: # ent package. If they match it will use them, otherwise it will new ones. autobind: - realm.pub/tavern/internal/ent - - realm.pub/tavern/internal/ent/file - - realm.pub/tavern/internal/ent/user - - realm.pub/tavern/internal/ent/tag - - realm.pub/tavern/internal/ent/beacon - - realm.pub/tavern/internal/ent/host - - realm.pub/tavern/internal/ent/hostprocess - - realm.pub/tavern/internal/ent/quest - - realm.pub/tavern/internal/ent/task - - realm.pub/tavern/internal/ent/tome struct_tag: json diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index d8d41300d..dddd3d262 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -537,9 +537,9 @@ type HostProcess implements Node { """Timestamp of when this ent was last updated""" lastModifiedAt: Time! """ID of the process.""" - pid: Int! + pid: Uint64! """ID of the parent process.""" - ppid: Int! + ppid: Uint64! """The name of the process.""" name: String! """The user the process is running as.""" @@ -627,23 +627,23 @@ input HostProcessWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int + pid: Uint64 + pidNEQ: Uint64 + pidIn: [Uint64!] + pidNotIn: [Uint64!] + pidGT: Uint64 + pidGTE: Uint64 + pidLT: Uint64 + pidLTE: Uint64 """ppid field predicates""" - ppid: Int - ppidNEQ: Int - ppidIn: [Int!] - ppidNotIn: [Int!] - ppidGT: Int - ppidGTE: Int - ppidLT: Int - ppidLTE: Int + ppid: Uint64 + ppidNEQ: Uint64 + ppidIn: [Uint64!] + ppidNotIn: [Uint64!] + ppidGT: Uint64 + ppidGTE: Uint64 + ppidLT: Uint64 + ppidLTE: Uint64 """name field predicates""" name: String nameNEQ: String diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index b85344a21..b706f0892 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -532,9 +532,9 @@ type HostProcess implements Node { """Timestamp of when this ent was last updated""" lastModifiedAt: Time! """ID of the process.""" - pid: Int! + pid: Uint64! """ID of the parent process.""" - ppid: Int! + ppid: Uint64! """The name of the process.""" name: String! """The user the process is running as.""" @@ -622,23 +622,23 @@ input HostProcessWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int + pid: Uint64 + pidNEQ: Uint64 + pidIn: [Uint64!] + pidNotIn: [Uint64!] + pidGT: Uint64 + pidGTE: Uint64 + pidLT: Uint64 + pidLTE: Uint64 """ppid field predicates""" - ppid: Int - ppidNEQ: Int - ppidIn: [Int!] - ppidNotIn: [Int!] - ppidGT: Int - ppidGTE: Int - ppidLT: Int - ppidLTE: Int + ppid: Uint64 + ppidNEQ: Uint64 + ppidIn: [Uint64!] + ppidNotIn: [Uint64!] + ppidGT: Uint64 + ppidGTE: Uint64 + ppidLT: Uint64 + ppidLTE: Uint64 """name field predicates""" name: String nameNEQ: String diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index d8d41300d..dddd3d262 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -537,9 +537,9 @@ type HostProcess implements Node { """Timestamp of when this ent was last updated""" lastModifiedAt: Time! """ID of the process.""" - pid: Int! + pid: Uint64! """ID of the parent process.""" - ppid: Int! + ppid: Uint64! """The name of the process.""" name: String! """The user the process is running as.""" @@ -627,23 +627,23 @@ input HostProcessWhereInput { lastModifiedAtLT: Time lastModifiedAtLTE: Time """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int + pid: Uint64 + pidNEQ: Uint64 + pidIn: [Uint64!] + pidNotIn: [Uint64!] + pidGT: Uint64 + pidGTE: Uint64 + pidLT: Uint64 + pidLTE: Uint64 """ppid field predicates""" - ppid: Int - ppidNEQ: Int - ppidIn: [Int!] - ppidNotIn: [Int!] - ppidGT: Int - ppidGTE: Int - ppidLT: Int - ppidLTE: Int + ppid: Uint64 + ppidNEQ: Uint64 + ppidIn: [Uint64!] + ppidNotIn: [Uint64!] + ppidGT: Uint64 + ppidGTE: Uint64 + ppidLT: Uint64 + ppidLTE: Uint64 """name field predicates""" name: String nameNEQ: String