Skip to content

Conversation

@PengyuanZhao
Copy link
Contributor

@PengyuanZhao PengyuanZhao commented Jun 3, 2025

Summary

This PR creates the package which serves functions to do preflight checks for GCP integrations including Agentless, AuditLog and Config

Depend on #1716

How did you test this change?

Run integration test: preflight_gcp_test.go

Run the following and check the output:

package main

import (
	"fmt"
	"os"

	"github.com/lacework/go-sdk/v2/lwpreflight/gcp"
)

func main() {
	preflight, err := gcp.New(gcp.Params{
		Agentless: true,
		Config:    true,
		AuditLog:  true,
		Region:    "us-west2",
		ProjectID: "abc-demo-project-123",
		CredentialsFile: "/Users/pengyuan/.config/gcloud/application_default_credentials.json",
	})
	if err != nil {
		fmt.Println(err)
		return
	}

	result, err := preflight.Run()
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Printf("%#v\n", result)
}

@PengyuanZhao PengyuanZhao requested a review from a team as a code owner June 3, 2025 15:04
@PengyuanZhao PengyuanZhao requested review from lwmobeent, marktabry and michaelhsiehlw and removed request for a team June 3, 2025 15:04
@PengyuanZhao PengyuanZhao changed the base branch from main to pengyuan/CAD-841 June 3, 2025 15:04
@github-actions
Copy link

github-actions bot commented Jun 3, 2025

Lacework Code Security found potential new issues in this PR.

sca found potential 2 new issues
		if limit := int64(maxReceiveMessageSize); limit < math.MaxInt64 {
			dcReader = io.LimitReader(dcReader, limit+1)
		}
		out, err := mem.ReadAll(dcReader, pool)
		if err != nil {
			out.Free()
			return nil, status.Errorf(codes.Internal, "grpc: failed to read decompressed data: %v", err)
		}

		if out.Len() > maxReceiveMessageSize {
			out.Free()
			return nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max %d", maxReceiveMessageSize)
		}

Base automatically changed from pengyuan/CAD-841 to main June 9, 2025 16:46
@lacework-code-security
Copy link

@lacework-code-security
Copy link

(Audit Mode) sca found potential 2 new issues
		if limit := int64(maxReceiveMessageSize); limit < math.MaxInt64 {
			dcReader = io.LimitReader(dcReader, limit+1)
		}
		out, err := mem.ReadAll(dcReader, pool)
		if err != nil {
			out.Free()
			return nil, status.Errorf(codes.Internal, "grpc: failed to read decompressed data: %v", err)
		}

		if out.Len() > maxReceiveMessageSize {
			out.Free()
			return nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max %d", maxReceiveMessageSize)
		}

Copy link
Collaborator

@lokesh-vadlamudi lokesh-vadlamudi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PengyuanZhao PengyuanZhao merged commit cf972bd into main Jun 10, 2025
13 checks passed
@PengyuanZhao PengyuanZhao deleted the pengyuan/CAD-842 branch June 10, 2025 16:10
@lacework-releng lacework-releng mentioned this pull request Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants