Skip to content

Commit eae81f7

Browse files
authored
fix: resource id would be empty when jsonPath get the wrong way (#72)
1 parent 0ee339e commit eae81f7

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

collector/aws/collector/ec2/flowlog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ func GetFlowLogResource() schema.Resource {
3434
Desc: "https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeFlowLogs.html",
3535
ResourceDetailFunc: GetFlowLogDetail,
3636
RowField: schema.RowField{
37-
ResourceId: "$.FlowLogId",
38-
ResourceName: "$.FlowLogId",
37+
ResourceId: "$.FlowLog.FlowLogId",
38+
ResourceName: "$.FlowLog.FlowLogId",
3939
},
4040
Dimension: schema.Regional,
4141
}

collector/aws/collector/ec2/networkinterface.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ func GetNetworkInterfaceResource() schema.Resource {
3434
Desc: "https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeNetworkInterfaces.html",
3535
ResourceDetailFunc: GetNetworkInterfaceDetail,
3636
RowField: schema.RowField{
37-
ResourceId: "$.NetworkInterfaceId",
38-
ResourceName: "$.NetworkInterfaceId",
37+
ResourceId: "$.NetworkInterface.NetworkInterfaceId",
38+
ResourceName: "$.NetworkInterface.NetworkInterfaceId",
3939
},
4040
Dimension: schema.Regional,
4141
}

collector/aws/collector/guardduty/detector.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ func GetDetectorResource() schema.Resource {
3636
Desc: `https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html`,
3737
ResourceDetailFunc: GetDetectorDetail,
3838
RowField: schema.RowField{
39-
ResourceId: "$.Detector.DetectorId",
40-
ResourceName: "$.Detector.DetectorId", // No friendly name
39+
ResourceId: "$.DetectorId",
40+
ResourceName: "$.DetectorId", // No friendly name
4141
},
4242
Dimension: schema.Regional,
4343
}
4444
}
4545

4646
// DetectorDetail aggregates all information for a single GuardDuty detector.
4747
type DetectorDetail struct {
48+
DetectorId string
4849
Detector *guardduty.GetDetectorOutput
4950
Administrator *types.Administrator
5051
Tags map[string]string
@@ -76,6 +77,7 @@ func GetDetectorDetail(ctx context.Context, service schema.ServiceInterface, res
7677
}
7778

7879
res <- &DetectorDetail{
80+
DetectorId: detectorId,
7981
Detector: detector,
8082
Administrator: administrator,
8183
Tags: tags,

collector/aws/collector/iam/account_settings.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func GetAccountSettingsResource() schema.Resource {
3535
Desc: `https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetAccountSummary.html`,
3636
ResourceDetailFunc: GetAccountSettingsDetail,
3737
RowField: schema.RowField{
38-
ResourceId: "", // AccountID would be
39-
ResourceName: "", // AccountID would be
38+
ResourceId: "$.AccountId", // AccountID would be
39+
ResourceName: "$.AccountId", // AccountID would be
4040
},
4141
Regions: []string{"ap-northeast-1", "cn-north-1"},
4242
Dimension: schema.Regional,
@@ -48,6 +48,8 @@ type AccountSettingsDetail struct {
4848

4949
AccountSummary map[string]int32
5050

51+
AccountId string
52+
5153
// todo
5254
//EnabledFeatures []types.FeatureType
5355
}
@@ -83,6 +85,7 @@ func describeAccountSettingsDetail(ctx context.Context, c *iam.Client) (AccountS
8385
return AccountSettingsDetail{
8486
PasswordPolicy: passwordPolicy,
8587
AccountSummary: accountSummary,
88+
AccountId: log.GetCloudAccountId(ctx),
8689
}, nil
8790
}
8891

collector/aws/collector/opensearch/domain.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func GetDomainResource() schema.Resource {
3535
Desc: "https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_DomainStatus.html",
3636
ResourceDetailFunc: GetDomainDetail,
3737
RowField: schema.RowField{
38-
ResourceId: "$.Domain.DomainId",
39-
ResourceName: "$.Domain.DomainName",
38+
ResourceId: "$.DomainStatus.DomainId",
39+
ResourceName: "$.DomainStatus.DomainName",
4040
},
4141
Dimension: schema.Regional,
4242
}

collector/aws/collector/sqs/queue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func GetSQSQueueResource() schema.Resource {
3737
Desc: "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ListQueues.html",
3838
ResourceDetailFunc: GetSQSQueueDetail,
3939
RowField: schema.RowField{
40-
ResourceId: "$.Queue.QueueUrl",
41-
ResourceName: "$.Queue.Name",
40+
ResourceId: "$.Url",
41+
ResourceName: "$.Name",
4242
},
4343
Dimension: schema.Regional,
4444
}
@@ -99,7 +99,7 @@ func describeSQSQueueDetail(ctx context.Context, client *sqs.Client, queue SQSQu
9999
} else {
100100
tags = tagMap
101101
}
102-
102+
103103
queue.Attributes = attributes
104104
queue.Policy = policy
105105
queue.Tags = tags

0 commit comments

Comments
 (0)