C-WCOW: SecurityPolicy implementation and tests - #2508
Conversation
e9c8277 to
3995b88
Compare
|
|
||
| // GetProcess returns the Process with the matching 'pid'. If the 'pid' does | ||
| // not exit returns error. | ||
| func (c *Container) GetProcess(pid uint32) (*containerProcess, error) { |
There was a problem hiding this comment.
Can this be moved to a new file named container.go?
Please move this method along with the declaration of container struct to that file. There should be a clear boundary between host methods vs container methods.
|
|
||
| if containerID == UVMContainerID { | ||
| log.G(req.ctx).Tracef("Enforcing policy on external exec process") | ||
| _, _, err := b.hostState.securityPolicyEnforcer.EnforceExecExternalProcessPolicy( |
There was a problem hiding this comment.
Do we need User validation in this enforcement point?
| // if this is an exec of Container command line, then it's already enforced | ||
| // during container creation, hence skip it here | ||
| containerCommandLine := escapeArgs(c.spec.Process.Args) | ||
| if processParams.CommandLine != containerCommandLine { |
There was a problem hiding this comment.
If another exec is made by the user with same command args as the original container, then this will not be enforced. Maybe we enforce all the exec including the container init exec.
| b.forwardRequestToGcs(req) | ||
|
|
||
| // fetch the process ID from response | ||
| deadline := time.Now().Add(5 * time.Second) |
There was a problem hiding this comment.
nit: Please declare the timeout at the beginning of the file so that we have a unified way for all the important constants.
| _ = sendWithContextCancel(ctx, sidecarErrChan, recverr) | ||
| return | ||
| } | ||
| // If this is a ContainerExecuteProcessResponse, notify |
There was a problem hiding this comment.
Instead of this approach, we can use channels for capturing the process response.
Approach would be-
- Create a channel on which you write the response to when the same is received in
ListenAndServeShimRequestsmethod. - Same channel is used in
executeProcessmethod. We listens on the channel with a deadline of 5 seconds. If you don't hear back then return an error message. If we hear back about another exec then we skip and keep waiting for next response.
With this approach, you won't need- b.pending, b.pendingMu and other polling logic.
| } | ||
| headerID := req.header.ID | ||
|
|
||
| // initiate process ID |
There was a problem hiding this comment.
Use channels instead of this logic. Please refer to earlier comment.
887b690 to
d0815d2
Compare
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
d0815d2 to
d744385
Compare
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
3098d26 to
9d6b64d
Compare
9d6b64d to
9ef1de2
Compare
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
9ef1de2 to
24fcf74
Compare
KenGordon
left a comment
There was a problem hiding this comment.
As discussed. Merge now (but do not delete the PR) and add some issues for the coding/style/refactoring that will be needed afterwards but which is not critical path for the demo and enabling others to get on with their work.
| SeccompProfileSHA256 string `json:"-"` | ||
| } | ||
|
|
||
| type WindowsContainer struct { |
There was a problem hiding this comment.
Can these various windows versions of pre-existing types be made common, either by using the go interface scheme (or whatever is appropriate - I can't claim to be a golang guru) or by just using the same objects but not filling out the parts that don't apply to the given platform?
This PR has dependency on commits from Invoke fsformatter for container scratch #2498. So, at the moment this is rebased on top of that PR.