Skip to content

Commit

Permalink
feat: add cloud account integration aws agentless scanning (#870)
Browse files Browse the repository at this point in the history
* feat: add cloud account integration aws agentless scanning
  • Loading branch information
dmurray-lacework authored Jul 27, 2022
1 parent e77d133 commit 8807a97
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
56 changes: 56 additions & 0 deletions api/_examples/cloud-accounts/aws-agentless-scanning/main.go
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)
}
2 changes: 2 additions & 0 deletions api/cloud_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const (
AwsCfgCloudAccount
AwsCtSqsCloudAccount
AwsEksAuditCloudAccount
AwsSidekickCloudAccount
AwsUsGovCfgCloudAccount
AwsUsGovCtSqsCloudAccount
AzureAlSeqCloudAccount
Expand All @@ -102,6 +103,7 @@ var CloudAccountTypes = map[cloudAccountType]string{
AwsCfgCloudAccount: "AwsCfg",
AwsCtSqsCloudAccount: "AwsCtSqs",
AwsEksAuditCloudAccount: "AwsEksAudit",
AwsSidekickCloudAccount: "AwsSidekick",
AwsUsGovCfgCloudAccount: "AwsUsGovCfg",
AwsUsGovCtSqsCloudAccount: "AwsUsGovCtSqs",
AzureAlSeqCloudAccount: "AzureAlSeq",
Expand Down
72 changes: 72 additions & 0 deletions api/cloud_accounts_aws_sidekick.go
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"`
}

0 comments on commit 8807a97

Please sign in to comment.