Skip to content

Commit

Permalink
Merge pull request firecracker-microvm#205 from mxpv/id
Browse files Browse the repository at this point in the history
Add VM ID validator
  • Loading branch information
mxpv authored Jun 11, 2019
2 parents 8fd1217 + 7f7605a commit ca4c8e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions firecracker-control/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"
"syscall"

"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/plugin"
Expand Down Expand Up @@ -79,8 +80,7 @@ func (s *local) CreateVM(requestCtx context.Context, req *proto.CreateVMRequest)
var err error

id := req.GetVMID()
if id == "" {
err = errors.New("invalid VM ID")
if err := identifiers.Validate(id); err != nil {
s.logger.WithError(err).Error()
return nil, err
}
Expand Down Expand Up @@ -184,6 +184,10 @@ func (s *local) CreateVM(requestCtx context.Context, req *proto.CreateVMRequest)
}

func (s *local) shimFirecrackerClient(requestCtx context.Context, vmID string) (*fcclient.Client, error) {
if err := identifiers.Validate(vmID); err != nil {
return nil, errors.Wrap(err, "invalid id")
}

socketAddr, err := fcShim.FCControlSocketAddress(requestCtx, vmID)
if err != nil {
err = errors.Wrap(err, "failed to get shim's fccontrol socket address")
Expand Down

0 comments on commit ca4c8e3

Please sign in to comment.