Skip to content

Commit

Permalink
feat(cli): new vulnerability evaluation command
Browse files Browse the repository at this point in the history
Here is a quick summary, with suppressed help output, of the changes to
the vulnerability commands:

Main Vulnerability Command:
```
$ lacework vulnerability -h

Available Commands:
  evaluation  review evaluations from assessed container images
  report      (deprecated) use 'evaluation show <sha256:hash>' instead
  scan        manage on-demand vulnerability scans
```

Vulnerability Evaluation Sub-Command:
```
$ lacework vulnerability evaluation -h

Available Commands:
  list        list all evaluations from a time range (default last 7 days)
  show        show results of a container image evaluation
```

Vulnerability Scan Sub-Command:
```
$ lacework vulnerability scan -h

Available Commands:
  run         request an on-demand vulnerability scan
  show        return results about an on-demand vulnerability scan
```

(DEPRECATED) Vulnerability Report Sub-Command:
```
$ lacework vulnerability report -h
(DEPRECATED) This command has been moved, use now the following command:

  $ lacework vulnerability evaluation show <sha256:hash>
```

Adds Deprecations #162
Closes #156

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Aug 17, 2020
1 parent c5c8cf4 commit 7e7191a
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 100 deletions.
1 change: 0 additions & 1 deletion api/vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func (svc *VulnerabilitiesService) ListEvaluationsDateRange(start, end time.Time
start.UTC().Format(time.RFC3339),
end.UTC().Format(time.RFC3339),
)
fmt.Println(apiPath)
err = svc.client.RequestDecoder("GET", apiPath, nil, &response)
return
}
Expand Down
27 changes: 1 addition & 26 deletions cli/cmd/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ time range.`,
err error
)
if eventsCmdState.Start != "" || eventsCmdState.End != "" {
start, end, errT := parseStartAndEndTime()
start, end, errT := parseStartAndEndTime(eventsCmdState.Start, eventsCmdState.End)
if errT != nil {
return errors.Wrap(errT, "unable to parse time range")
}
Expand Down Expand Up @@ -899,28 +899,3 @@ func eventMachineEntitiesTable(machines []api.EventMachineEntity) string {

return r.String()
}

// parse the start and end time provided by the user
func parseStartAndEndTime() (start time.Time, end time.Time, err error) {
if eventsCmdState.Start == "" {
err = errors.New("when providing an end time, start time should be provided (--start)")
return
}
start, err = time.Parse(time.RFC3339, eventsCmdState.Start)
if err != nil {
err = errors.Wrap(err, "unable to parse start time")
return
}

if eventsCmdState.End == "" {
err = errors.New("when providing a start time, end time should be provided (--end)")
return
}
end, err = time.Parse(time.RFC3339, eventsCmdState.End)
if err != nil {
err = errors.Wrap(err, "unable to parse end time")
return
}

return
}
50 changes: 50 additions & 0 deletions cli/cmd/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Author:: Salim Afiune Maya (<[email protected]>)
// Copyright:: Copyright 2020, Lacework Inc.
// License:: Apache License, Version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package cmd

import (
"time"

"github.com/pkg/errors"
)

// parse the start and end time provided by the user
func parseStartAndEndTime(s, e string) (start time.Time, end time.Time, err error) {
if s == "" {
err = errors.New("when providing an end time, start time should be provided (--start)")
return
}
start, err = time.Parse(time.RFC3339, s)
if err != nil {
err = errors.Wrap(err, "unable to parse start time")
return
}

if e == "" {
err = errors.New("when providing a start time, end time should be provided (--end)")
return
}
end, err = time.Parse(time.RFC3339, e)
if err != nil {
err = errors.Wrap(err, "unable to parse end time")
return
}

return
}
Loading

0 comments on commit 7e7191a

Please sign in to comment.