Skip to content

Commit

Permalink
UD-7238: Adds files to support the hub rapid scans. Implements the fi…
Browse files Browse the repository at this point in the history
…rst method to kick-off a rapid scan.
  • Loading branch information
christianprando committed Apr 8, 2021
1 parent bdf86cf commit d90bf48
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hubapi/rapid-scans-api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2021 Synopsys, Inc.
//
// 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 hubapi

const (
ContentTypeRapidScan = "application/vnd.blackducksoftware.developer-scan-1-ld-2+json"
)
36 changes: 36 additions & 0 deletions hubclient/rapid-scans-client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2021 Synopsys, Inc.
//
// 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 hubclient

import (
"github.com/blackducksoftware/hub-client-go/hubapi"
log "github.com/sirupsen/logrus"
)

const (
apiDeveloperScans = "/api/developer-scans"
)

func (c *Client) StartRapidScan(bdioHeaderContent string) (error, string) {
rapidScansURL := c.baseURL + apiDeveloperScans
result, err := c.HttpPostJSON(rapidScansURL, bdioHeaderContent, hubapi.ContentTypeRapidScan, 200)

if err != nil {
log.Errorf("Error kicking off a rapid scan.", err)
return err, ""
}

return nil, result
}

0 comments on commit d90bf48

Please sign in to comment.