-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cloud account integration aws agentless scanning (#870)
* feat: add cloud account integration aws agentless scanning
- Loading branch information
1 parent
e77d133
commit 8807a97
Showing
3 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
api/_examples/cloud-accounts/aws-agentless-scanning/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/lacework/go-sdk/api" | ||
) | ||
|
||
func main() { | ||
lacework, err := api.NewClient(os.Getenv("LW_ACCOUNT"), | ||
api.WithSubaccount(os.Getenv("LW_SUBACCOUNT")), | ||
api.WithApiKeys(os.Getenv("LW_API_KEY"), os.Getenv("LW_API_SECRET")), | ||
api.WithApiV2(), | ||
) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
res, err := lacework.V2.CloudAccounts.List() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
for _, account := range res.Data { | ||
support := "Unsupported" | ||
switch account.Type { | ||
case api.AwsSidekickCloudAccount.String(): | ||
support = "Supported" | ||
} | ||
|
||
// Output: INTEGRATION-GUID:INTEGRATION-TYPE:[Supported|Unsupported] | ||
fmt.Printf("%s:%s:%s\n", account.IntgGuid, account.Type, support) | ||
} | ||
|
||
awsSidekickData := api.AwsSidekickData{ | ||
ScanFrequency: 24, | ||
ScanContainers: true, | ||
ScanHostVulnerabilities: true, | ||
} | ||
|
||
awsSidekickAccount := api.NewCloudAccount( | ||
fmt.Sprintf("%s-from-golang", api.AwsSidekickCloudAccount.String()), | ||
api.AwsSidekickCloudAccount, | ||
awsSidekickData, | ||
) | ||
|
||
awsSidekickResponse, err := lacework.V2.CloudAccounts.CreateAwsSidekick(awsSidekickAccount) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Output: AwsSidekick Cloud Account created: THE-INTEGRATION-GUID | ||
fmt.Printf("Cloud Account created: %s", awsSidekickResponse.Data.IntgGuid) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// Author:: Darren Murray(<[email protected]>) | ||
// Copyright:: Copyright 2022, 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 api | ||
|
||
// GetAwsSidekick gets a single AwsSidekick integration matching the provided integration guid | ||
func (svc *CloudAccountsService) GetAwsSidekick(guid string) ( | ||
response AwsSidekickResponse, | ||
err error, | ||
) { | ||
err = svc.get(guid, &response) | ||
return | ||
} | ||
|
||
// CreateAwsSidekick creates an AwsSidekick Cloud Account integration | ||
func (svc *CloudAccountsService) CreateAwsSidekick(data CloudAccount) ( | ||
response AwsSidekickResponse, | ||
err error, | ||
) { | ||
err = svc.create(data, &response) | ||
return | ||
} | ||
|
||
// UpdateAwsSidekick updates a single AwsSidekick integration on the Lacework Server | ||
func (svc *CloudAccountsService) UpdateAwsSidekick(data CloudAccount) ( | ||
response AwsSidekickResponse, | ||
err error, | ||
) { | ||
err = svc.update(data.ID(), data, &response) | ||
return | ||
} | ||
|
||
type AwsSidekickResponse struct { | ||
Data AwsSidekick `json:"data"` | ||
} | ||
|
||
type AwsSidekick struct { | ||
v2CommonIntegrationData | ||
awsSidekickToken `json:"serverToken"` | ||
Data AwsSidekickData `json:"data"` | ||
} | ||
|
||
type awsSidekickToken struct { | ||
ServerToken string `json:"serverToken"` | ||
Uri string `json:"uri"` | ||
} | ||
|
||
type AwsSidekickData struct { | ||
//QueryText represents an lql json string | ||
QueryText string `json:"queryText,omitempty"` | ||
|
||
//ScanFrequency in hours, 24 == 24 hours | ||
ScanFrequency int `json:"scanFrequency"` | ||
|
||
ScanContainers bool `json:"scanContainers"` | ||
ScanHostVulnerabilities bool `json:"scanHostVulnerabilities"` | ||
} |