Open jvehent opened 8 years ago
Part of this was addressed in #176
Removing action parameters from responses still needs to be addressed.
Hello, I am just starting to contribute to the project. I would like to know what exactly are this "action parameters". Is it the field "Action" in the Command struct here? And what would be the best approach to remove it, please?
That's the correct place to look.
Basically what happens is, when a new command comes into the agent to be run, it eventually ends up here:
https://github.com/mozilla/mig/blob/3f053d476aacbdfefb16823e1b745a75121ca703/mig-agent/agent.go#L596
and msg
is turned into a mig.Command
:
The command Action
element is what the agent should do, and it can do more than one thing per action so within here you will see a list of operations, where each operation describes the parameters that should be used when the module is run for that operation.
https://github.com/mozilla/mig/blob/3f053d476aacbdfefb16823e1b745a75121ca703/action.go#L39
Inside a given operation, Parameters
is the data we are referring to here that we want to remove in the response.
https://github.com/mozilla/mig/blob/3f053d476aacbdfefb16823e1b745a75121ca703/action.go#L85
Once the agent is done executing modules for the operations, the results are added back to the same command type we started with at the beginning.
https://github.com/mozilla/mig/blob/3f053d476aacbdfefb16823e1b745a75121ca703/mig-agent/agent.go#L856
and then the completed command is sent to the Results channel, where the agent will forward it back to the scheduler.
The issue here is that command we are sending to the channel, still contains all of the parameters that were supplied to run the module. In some cases, this can be quite a bit of data (like parameters for the scribe module). We want to just remove that since we only care about the results coming back and don't need the original action parameters.
At first glance I am thinking one way to do this would be to add a new method on the Command
type, maybe something like PruneActionParameters. This would essentially iterate over all operations in Command.Action
, and remove them.
So in the previous highlighted statement, it might end up looking something like:
err = cmd.PruneActionParameters()
if err != nil {
panic(err)
}
ctx.Channels.Results <- cmd
Just to clarify my original comment to, we wouldn't want to remove the operations, but what we'd want to do is likely just set the Parameters value in the operation to nil.
@ameihm0912 Thank you very much for the clarification. Working on the fix.
@ameihm0912 I just have 3 doubts:
Thank you
As we start running very large actions for vulnerability management, it's becoming important to reduce the amount of data that goes through the messaging pipeline. This can be done in two places:
Compression of command results could be implemented as well, similarly to 1.