Skip to content

Commit e639940

Browse files
MahatiCkiashok
authored andcommitted
CWCOW: Implement security policy
Signed-off-by: Mahati Chamarthy <mchamarthy@microsoft.com>
1 parent ae683b2 commit e639940

11 files changed

Lines changed: 960 additions & 120 deletions

File tree

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,
@@ -378,6 +382,23 @@ func (b *Bridge) ListenAndServeShimRequests() error {
378382
logrus.Error(recverr)
379383
break
380384
}
385+
// If this is a ContainerExecuteProcessResponse, notify
386+
const MsgExecuteProcessResponse prot.MsgType = prot.MsgTypeResponse | prot.MsgType(prot.RPCExecuteProcess)
387+
388+
if header.Type == MsgExecuteProcessResponse {
389+
logrus.Tracef("Printing after inbox exec resp")
390+
var procResp prot.ContainerExecuteProcessResponse
391+
if err := json.Unmarshal(message, &procResp); err != nil {
392+
logrus.Tracef("unmarshal failed")
393+
}
394+
395+
b.pendingMu.Lock()
396+
if _, exists := b.pending[header.ID]; exists {
397+
logrus.Tracef("Header ID in pending exists")
398+
b.pending[header.ID] = &procResp
399+
}
400+
b.pendingMu.Unlock()
401+
}
381402

382403
// Forward to shim
383404
resp := bridgeResponse{

0 commit comments

Comments
 (0)