Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose gcp.resourceLabels field in the gcp plugin #545

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/gcpaudit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ For more details about what Cloud logging log queries, see the [GCP official doc
| `gcp.projectId` | `string` | None | GCP project ID |
| `gcp.resourceName` | `string` | None | GCP resource name |
| `gcp.resourceType` | `string` | None | GCP resource type |
| `gcp.resourceLabels` | `string` | None | GCP resource labels |
| `gcp.storage.bucket` | `string` | None | GCP bucket name |
<!-- /README-PLUGIN-FIELDS -->

Expand Down
7 changes: 7 additions & 0 deletions plugins/gcpaudit/pkg/gcpaudit/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (p *Plugin) Fields() []sdk.FieldEntry {
{Type: "string", Name: "gcp.projectId", Display: "Project ID", Desc: "GCP project ID"},
{Type: "string", Name: "gcp.resourceName", Display: "Resource Name", Desc: "GCP resource name"},
{Type: "string", Name: "gcp.resourceType", Display: "Resource Type", Desc: "GCP resource type"},
{Type: "string", Name: "gcp.resourceLabels", Display: "Resource Labels", Desc: "GCP resource labels"},
{Type: "string", Name: "gcp.storage.bucket", Display: "Bucket Name", Desc: "GCP bucket name"},
}
}
Expand Down Expand Up @@ -225,6 +226,12 @@ func (p *Plugin) Extract(req sdk.ExtractRequest, evt sdk.EventReader) error {
req.SetValue(string(resourceType))
}

case "gcp.resourceLabels":
resourceLabels := p.jdata.Get("resource").Get("labels").MarshalTo(nil)
if resourceLabels != nil && len(resourceLabels) > 0 {
req.SetValue(string(resourceLabels))
}

case "gcp.storage.bucket":
bucket := p.jdata.Get("resource").Get("labels").GetStringBytes("bucket_name")
if bucket != nil {
Expand Down
2 changes: 1 addition & 1 deletion plugins/gcpaudit/pkg/gcpaudit/gcpaudit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
PluginName = "gcpaudit"
PluginDescription = "Read GCP Audit Logs"
PluginContact = "github.com/falcosecurity/plugins"
PluginVersion = "0.4.0"
PluginVersion = "0.5.0"
PluginEventSource = "gcp_auditlog"
)

Expand Down
Loading