Skip to content

Commit bfe9b40

Browse files
authored
Merge pull request #45 from MahatiC/security-policy-cwcow
Implement security policy for CWCOW
2 parents d33c1a3 + d0b6741 commit bfe9b40

File tree

12 files changed

+1005
-125
lines changed

12 files changed

+1005
-125
lines changed

internal/gcs-sidecar/bridge.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import (
3232

3333
type Bridge struct {
3434
mu sync.Mutex
35+
pendingMu sync.Mutex
36+
pending map[sequenceID]*prot.ContainerExecuteProcessResponse
37+
3538
hostState *Host
3639
// List of handlers for handling different rpc message requests.
3740
rpcHandlerList map[prot.RPCProc]HandlerFunc
@@ -77,6 +80,7 @@ type request struct {
7780
func NewBridge(shimConn io.ReadWriteCloser, inboxGCSConn io.ReadWriteCloser, initialEnforcer securitypolicy.SecurityPolicyEnforcer) *Bridge {
7881
hostState := NewHost(initialEnforcer)
7982
return &Bridge{
83+
pending: make(map[sequenceID]*prot.ContainerExecuteProcessResponse),
8084
rpcHandlerList: make(map[prot.RPCProc]HandlerFunc),
8185
hostState: hostState,
8286
shimConn: shimConn,
@@ -375,6 +379,23 @@ func (b *Bridge) ListenAndServeShimRequests() error {
375379
logrus.Error(recverr)
376380
break
377381
}
382+
// If this is a ContainerExecuteProcessResponse, notify
383+
const MsgExecuteProcessResponse prot.MsgType = prot.MsgTypeResponse | prot.MsgType(prot.RPCExecuteProcess)
384+
385+
if header.Type == MsgExecuteProcessResponse {
386+
logrus.Tracef("Printing after inbox exec resp")
387+
var procResp prot.ContainerExecuteProcessResponse
388+
if err := json.Unmarshal(message, &procResp); err != nil {
389+
logrus.Tracef("unmarshal failed")
390+
}
391+
392+
b.pendingMu.Lock()
393+
if _, exists := b.pending[header.ID]; exists {
394+
logrus.Tracef("Header ID in pending exists")
395+
b.pending[header.ID] = &procResp
396+
}
397+
b.pendingMu.Unlock()
398+
}
378399

379400
// Forward to shim
380401
resp := bridgeResponse{

0 commit comments

Comments
 (0)