Skip to content

Commit

Permalink
fix: Merge branch 'main' of ssh://github.com/lacework/go-sdk into RAI…
Browse files Browse the repository at this point in the history
…N-93116-cli-guided-config-azure-ad
  • Loading branch information
Manan-Bhatia-0 committed Aug 15, 2024
2 parents 302cf3d + d25c70d commit 0d8db6a
Show file tree
Hide file tree
Showing 27 changed files with 179 additions and 715 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Global rule:
* @lacework/growth-team
* @lacework/eng-product-platform
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# v1.52.0

## Features
* feat(GROW-2949): Provide organization_id for project level agentless integration (#1648) (Lei Jin)([152359d3](https://github.com/lacework/go-sdk/commit/152359d3ee25effd49e301f1d1db0d77a4f7aa97))
## Bug Fixes
* fix(GROW-2950): disable use of gcp storage audit from generate (#1643) (Matt Cadorette)([5edd4cad](https://github.com/lacework/go-sdk/commit/5edd4cad417dacd13400e5e40ffed6d87601604f))
* fix: vuln integration test host id (#1645) (Matt Cadorette)([3cfc4caa](https://github.com/lacework/go-sdk/commit/3cfc4caa32711d45e75724e35786b7fc26a59e16))
## Other Changes
* chore: Add uuid for resource group tests (#1651) (Lei Jin)([cbe5213a](https://github.com/lacework/go-sdk/commit/cbe5213a1685dc93be2c5c6e20caf8a89a3830f7))
* chore(GROW-2952): update codeowners (#1647) (Matt Cadorette)([889c40ae](https://github.com/lacework/go-sdk/commit/889c40aee2f816c2d45815ac679d71c3a2d085ba))
* chore(RAIN-93468): Remove use of the queryLanguage query property (#1638) (gspofford-lw)([eb8d5c1f](https://github.com/lacework/go-sdk/commit/eb8d5c1f466d10e6a40612094c145e18ab7bc372))
* ci: version bump to v1.51.1-dev (Lacework)([31adf212](https://github.com/lacework/go-sdk/commit/31adf212216ef685d7b8d2237921d010e2b977ce))
---
# v1.51.0

## Features
Expand Down
20 changes: 8 additions & 12 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# Release Notes
Another day, another release. These are the release notes for the version `v1.51.0`.
Another day, another release. These are the release notes for the version `v1.52.0`.

## Features
* feat: prosast component data upload (#1639) (jonathan stewart)([635f2d30](https://github.com/lacework/go-sdk/commit/635f2d30643ce70c3ebd6b0c49542954a5e7a828))
* feat(GROW-2928): Upgrade the gcp terraform version (#1637) (Lei Jin)([02bcccab](https://github.com/lacework/go-sdk/commit/02bcccabd229620b4d08755b95615d4f4c17a71a))
* feat(GROW-2931): Add support for GCP default labels (#1633) (Lei Jin)([6d765866](https://github.com/lacework/go-sdk/commit/6d765866a99a07e3cb0bf0ccc9eaa73612b2f3c4))
* feat(GROW-2929): update lwgenerate to support GCP generation (#1631) (Lei Jin)([2c64710e](https://github.com/lacework/go-sdk/commit/2c64710ee725d77d7341274e940dc5cec27d3c3d))
* feat(GROW-2819): enable custom blocks with azure generate (#1630) (Matt Cadorette)([67c7bbc9](https://github.com/lacework/go-sdk/commit/67c7bbc9b88a7492fa3d387d44d5e1f290eef79e))
* feat(GROW-2908): lwgenerate enable custom root terraform blocks and provider arguments (#1626) (Matt Cadorette)([8d50d317](https://github.com/lacework/go-sdk/commit/8d50d317e44bf379523c0138fcb12ec34b4ed302))
* feat(GROW-2883): lwgenerate enable adding aws provider default tags (#1623) (Matt Cadorette)([5d6ef3df](https://github.com/lacework/go-sdk/commit/5d6ef3dfbbc1349abaf5e1c0fca325f0ac65960a))
* feat(GROW-2949): Provide organization_id for project level agentless integration (#1648) (Lei Jin)([152359d3](https://github.com/lacework/go-sdk/commit/152359d3ee25effd49e301f1d1db0d77a4f7aa97))
## Bug Fixes
* fix(GROW-2931): GCP default label should be attributes (#1636) (Lei Jin)([e575eac8](https://github.com/lacework/go-sdk/commit/e575eac82b34e8a9ce840928d6f73e13675291e0))
* fix(GROW-2819): split azuread/azurerm gen args (#1632) (Matt Cadorette)([6ae460a7](https://github.com/lacework/go-sdk/commit/6ae460a7212365947c80889ec0ff02499a05bdd5))
* fix(GROW-2950): disable use of gcp storage audit from generate (#1643) (Matt Cadorette)([5edd4cad](https://github.com/lacework/go-sdk/commit/5edd4cad417dacd13400e5e40ffed6d87601604f))
* fix: vuln integration test host id (#1645) (Matt Cadorette)([3cfc4caa](https://github.com/lacework/go-sdk/commit/3cfc4caa32711d45e75724e35786b7fc26a59e16))
## Other Changes
* chore: update cloud-account migrate cmd desc (#1625) (Manan Bhatia)([8c76d482](https://github.com/lacework/go-sdk/commit/8c76d482af778977c8eeb35c150fea9e1fed7be1))
* ci: version bump to v1.50.1-dev (Lacework)([f469da52](https://github.com/lacework/go-sdk/commit/f469da5287671e0ef893df381b6e64ae4530c50d))
* chore: Add uuid for resource group tests (#1651) (Lei Jin)([cbe5213a](https://github.com/lacework/go-sdk/commit/cbe5213a1685dc93be2c5c6e20caf8a89a3830f7))
* chore(GROW-2952): update codeowners (#1647) (Matt Cadorette)([889c40ae](https://github.com/lacework/go-sdk/commit/889c40aee2f816c2d45815ac679d71c3a2d085ba))
* chore(RAIN-93468): Remove use of the queryLanguage query property (#1638) (gspofford-lw)([eb8d5c1f](https://github.com/lacework/go-sdk/commit/eb8d5c1f466d10e6a40612094c145e18ab7bc372))
* ci: version bump to v1.51.1-dev (Lacework)([31adf212](https://github.com/lacework/go-sdk/commit/31adf212216ef685d7b8d2237921d010e2b977ce))

## :whale: [Docker Image](https://hub.docker.com/r/lacework/lacework-cli)
```
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.51.1-dev
1.52.1-dev
16 changes: 2 additions & 14 deletions api/lql.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import (
)

type NewQuery struct {
QueryID string `json:"queryId" yaml:"queryId"`
QueryLanguage *string `json:"queryLanguage,omitempty" yaml:"queryLanguage,omitempty"`
QueryText string `json:"queryText" yaml:"queryText"`
QueryID string `json:"queryId" yaml:"queryId"`
QueryText string `json:"queryText" yaml:"queryText"`
}

func ParseNewQuery(s string) (NewQuery, error) {
Expand All @@ -50,7 +49,6 @@ func ParseNewQuery(s string) (NewQuery, error) {
if err == nil && !reflect.DeepEqual(query, NewQuery{}) { // empty string unmarshals w/o error
return query, nil
}

// invalid query
return query, errors.New("unable to parse query")
}
Expand All @@ -61,7 +59,6 @@ type UpdateQuery struct {

type Query struct {
QueryID string `json:"queryId" yaml:"queryId"`
QueryLanguage *string `json:"queryLanguage,omitempty" yaml:"queryLanguage,omitempty"`
QueryText string `json:"queryText" yaml:"queryText"`
Owner string `json:"owner"`
LastUpdateTime string `json:"lastUpdateTime"`
Expand Down Expand Up @@ -134,12 +131,3 @@ func (svc *QueryService) Get(id string) (
)
return
}

func (svc *QueryService) RegoQueryEnabled() bool {
response, err := svc.client.V2.FeatureFlags.GetFeatureFlagsMatchingPrefix("PUBLIC.lpp_rego_enabled")
if err != nil {
return false
}

return len(response.Data.Flags) >= 1
}
61 changes: 5 additions & 56 deletions api/lql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"testing"

"github.com/pkg/errors"
"github.com/stretchr/testify/assert"

"github.com/lacework/go-sdk/api"
"github.com/lacework/go-sdk/internal/lacework"
"github.com/lacework/go-sdk/internal/pointer"
)

var (
Expand All @@ -48,23 +46,6 @@ var (
queryId: %s
queryText: %s`, newQuery.QueryID, newQuery.QueryText)
lqlErrorReponse = `{ "message": "This is an error message" }`

regoQueryID = "my_rego"
newRegoQueryText = "package clitest\n" +
"import future.keywords\n" +
"import data.lacework\n" +
"source := lacework.aws.cfg.list(\"s3\", \"list-buckets\")\n" +
"assess := assessment.violation(input, \"just because\")"
newRegoQuery = api.NewQuery{
QueryID: regoQueryID,
QueryLanguage: pointer.Of("Rego"),
QueryText: newRegoQueryText,
}
newRegoQueryJSON = fmt.Sprintf(`{
"queryId": "%s",
"queryLanguage": "Rego",
"queryText": %#v
}`, queryID, newRegoQueryText)
)

func mockQueryDataResponse(data string) string {
Expand Down Expand Up @@ -148,8 +129,8 @@ func TestQueryCreateMethod(t *testing.T) {
assert.Nil(t, err)
}

func createQueryOKTestHelper(t *testing.T, expectedResponseData string, testQuery api.NewQuery) {
mockResponse := mockQueryDataResponse(expectedResponseData)
func TestQueryCreateOK(t *testing.T) {
mockResponse := mockQueryDataResponse(newQueryJSON)

fakeServer := lacework.MockServer()
fakeServer.MockAPI(
Expand All @@ -170,26 +151,10 @@ func createQueryOKTestHelper(t *testing.T, expectedResponseData string, testQuer
_ = json.Unmarshal([]byte(mockResponse), &createExpected)

var createActual api.QueryResponse
createActual, err = c.V2.Query.Create(testQuery)
createActual, err = c.V2.Query.Create(newQuery)
assert.Nil(t, err)

assert.Equal(t, createExpected, createActual)

if strings.Contains(expectedResponseData, "queryLanguage") {
assert.Equal(t, "Rego", *createActual.Data.QueryLanguage)
} else {
assert.Nil(t, createActual.Data.QueryLanguage)
}
}

func TestLQLQueryCreateOK(t *testing.T) {
// queryLanguage is not available
createQueryOKTestHelper(t, newQueryJSON, newQuery)
}

func TestRegoQueryCreateOK(t *testing.T) {
// queryLanguage is available
createQueryOKTestHelper(t, newRegoQueryJSON, newRegoQuery)
}

func TestQueryCreateError(t *testing.T) {
Expand Down Expand Up @@ -233,8 +198,8 @@ func TestQueryListMethod(t *testing.T) {
assert.Nil(t, err)
}

func getQueryByIDTestHelper(t *testing.T, expectedResponseData string, queryId string) {
mockResponse := mockQueryDataResponse(expectedResponseData)
func TestQueryGetQueryByIDOK(t *testing.T) {
mockResponse := mockQueryDataResponse(newQueryJSON)

fakeServer := lacework.MockServer()
fakeServer.MockAPI(
Expand All @@ -260,22 +225,6 @@ func getQueryByIDTestHelper(t *testing.T, expectedResponseData string, queryId s
assert.Nil(t, err)

assert.Equal(t, getExpected, getActual)

if strings.Contains(expectedResponseData, "queryLanguage") {
assert.Equal(t, "Rego", *getActual.Data.QueryLanguage)
} else {
assert.Nil(t, getActual.Data.QueryLanguage)
}
}

func TestLQLQueryGetQueryByIDOK(t *testing.T) {
// queryLanguage is not available
getQueryByIDTestHelper(t, newQueryJSON, queryID)
}

func TestRegoQueryGetQueryByIDOK(t *testing.T) {
// queryLanguage is available
getQueryByIDTestHelper(t, newRegoQueryJSON, regoQueryID)
}

func TestQueryGetNotFound(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions api/lql_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
package api

type ValidateQuery struct {
QueryText string `json:"queryText"`
QueryLanguage *string `json:"queryLanguage,omitempty" yaml:"queryLanguage,omitempty"`
QueryText string `json:"queryText"`
}

func (svc *QueryService) Validate(vq ValidateQuery) (
Expand Down
9 changes: 0 additions & 9 deletions api/lql_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

"github.com/lacework/go-sdk/api"
"github.com/lacework/go-sdk/internal/lacework"
"github.com/lacework/go-sdk/internal/pointer"
)

var (
Expand Down Expand Up @@ -89,14 +88,6 @@ func TestLQLQueryValidateOK(t *testing.T) {
testQueryValidateOKHelper(t, newQueryJSON, validateQuery)
}

func TestRegoQueryValidateOK(t *testing.T) {
validateRegoQuery := api.ValidateQuery{
QueryText: newRegoQueryText,
QueryLanguage: pointer.Of("Rego"),
}
testQueryValidateOKHelper(t, newRegoQueryJSON, validateRegoQuery)
}

func TestQueryValidateError(t *testing.T) {
fakeServer := lacework.MockServer()
fakeServer.MockAPI(
Expand Down
4 changes: 1 addition & 3 deletions api/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ import (
"reflect"
"time"

"github.com/lacework/go-sdk/internal/array"
"github.com/pkg/errors"
"gopkg.in/yaml.v3"

"github.com/lacework/go-sdk/internal/array"
)

// PolicyService is a service that interacts with the Custom Policies
Expand Down Expand Up @@ -177,7 +176,6 @@ type Policy struct {
PolicyID string `json:"policyId" yaml:"policyId"`
PolicyType string `json:"policyType" yaml:"-"`
QueryID string `json:"queryId" yaml:"queryId"`
QueryLanguage *string `json:"queryLanguage,omitempty" yaml:"queryLanguage,omitempty"`
Title string `json:"title" yaml:"title"`
Enabled bool `json:"enabled" yaml:"enabled"`
Description string `json:"description" yaml:"description"`
Expand Down
53 changes: 6 additions & 47 deletions api/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
"testing"

"github.com/aws/smithy-go/ptr"
"github.com/stretchr/testify/assert"

"github.com/lacework/go-sdk/lwseverity"
"github.com/stretchr/testify/assert"

"github.com/lacework/go-sdk/api"
"github.com/lacework/go-sdk/internal/lacework"
Expand Down Expand Up @@ -122,38 +121,6 @@ var (
]
}
`

regoPolicyId = "rego-policy-1"
regoPolicy = api.NewPolicy{
PolicyID: regoPolicyId,
PolicyType: "Violation",
QueryID: "MyRegoQuery",
Title: "My Rego Policy Title",
Enabled: false,
Description: "My Policy Description",
Remediation: "Check yourself...",
Severity: "high",
EvalFrequency: "Hourly",
Limit: 1000,
AlertEnabled: false,
AlertProfile: "LW_CloudTrail_Alerts",
}
regoPolicyCreateData = fmt.Sprintf(`{
"policyId": "%s",
"policyType": "%s",
"queryId": "%s",
"title": "%s",
"enabled": %v,
"description": "%s",
"remediation": "%s",
"severity": "%s",
"evalFrequency": "%s",
"limit": %d,
"alertEnabled": %v,
"alertProfile": "%s"
}`, regoPolicy.PolicyID, regoPolicy.PolicyType, regoPolicy.QueryID, regoPolicy.Title,
regoPolicy.Enabled, regoPolicy.Description, regoPolicy.Remediation, regoPolicy.Severity,
regoPolicy.EvalFrequency, regoPolicy.Limit, regoPolicy.AlertEnabled, regoPolicy.AlertProfile)
)

func mockPolicyDataResponse(data string) string {
Expand Down Expand Up @@ -189,7 +156,7 @@ func TestPolicyCreateMethod(t *testing.T) {
assert.Nil(t, err)
}

func TestLqlPolicyCreateOK(t *testing.T) {
func TestPolicyCreateOK(t *testing.T) {
mockResponse := mockPolicyDataResponse(policyCreateData)

fakeServer := lacework.MockServer()
Expand Down Expand Up @@ -256,12 +223,12 @@ func TestPolicyGetMethod(t *testing.T) {
assert.Nil(t, err)
}

func testPolicyGetOKHelper(t *testing.T, expectedPolicyData string, testPolicyId string) {
mockResponse := mockPolicyDataResponse(expectedPolicyData)
func TestPolicyGetOK(t *testing.T) {
mockResponse := mockPolicyDataResponse(policyCreateData)

fakeServer := lacework.MockServer()
fakeServer.MockAPI(
fmt.Sprintf("%s/%s", policyURI, testPolicyId),
fmt.Sprintf("%s/%s", policyURI, policyID),
func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, mockResponse)
},
Expand All @@ -278,20 +245,12 @@ func testPolicyGetOKHelper(t *testing.T, expectedPolicyData string, testPolicyId
_ = json.Unmarshal([]byte(mockResponse), &getExpected)

var getActual api.PolicyResponse
getActual, err = c.V2.Policy.Get(testPolicyId)
getActual, err = c.V2.Policy.Get(policyID)
assert.Nil(t, err)

assert.Equal(t, getExpected, getActual)
}

func TestLQLPolicyGetOK(t *testing.T) {
testPolicyGetOKHelper(t, policyCreateData, policyID)
}

func TestRegoPolicyGetOK(t *testing.T) {
testPolicyGetOKHelper(t, regoPolicyCreateData, regoPolicyId)
}

func TestPolicyGetNotFound(t *testing.T) {
fakeServer := lacework.MockServer()
fakeServer.MockAPI(
Expand Down
4 changes: 2 additions & 2 deletions api/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions cli/cdk/go/proto/v1/cdk.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/cdk/go/proto/v1/cdk_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0d8db6a

Please sign in to comment.