Skip to content

Commit

Permalink
Merge branch 'main' into feature/aws-neptune
Browse files Browse the repository at this point in the history
  • Loading branch information
sethsec-bf authored Feb 27, 2024
2 parents 80c00f3 + 1ca5dbf commit 15e0507
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion aws/env-vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ func (m *EnvsModule) interestingEnvVarsOnly() [][]string {
for _, envVar := range m.EnvironmentVariables {
if envVar.interesting {
interestingBody = append(
m.output.Body, []string{
interestingBody, []string{
aws.ToString(m.Caller.Account),
envVar.service,
envVar.region,
Expand Down
37 changes: 19 additions & 18 deletions aws/role-trusts.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,33 +241,34 @@ func (m *RoleTrustsModule) printPrincipalTrusts(outputDirectory string) ([]strin
for _, role := range m.AnalyzedRoles {
for _, statement := range role.trustsDoc.Statement {
for _, principal := range statement.Principal.AWS {
if strings.Contains(principal, ":root") {
//check to see if the accountID is known
//check to see if the accountID is known
if strings.Contains(principal, "arn:aws:iam::") || strings.Contains(principal, "root") {
accountID := strings.Split(principal, ":")[4]
vendorName := m.vendors.GetVendorNameFromAccountID(accountID)
if vendorName != "" {
principal = fmt.Sprintf("%s (%s)", principal, vendorName)
}
}

RoleTrustRow := RoleTrustRow{
RoleARN: aws.ToString(role.roleARN),
RoleName: GetResourceNameFromArn(aws.ToString(role.roleARN)),
TrustedPrincipal: principal,
ExternalID: statement.Condition.StringEquals.StsExternalID,
IsAdmin: role.Admin,
CanPrivEsc: role.CanPrivEsc,
}
body = append(body, []string{
aws.ToString(m.Caller.Account),
RoleTrustRow.RoleARN,
RoleTrustRow.RoleName,
RoleTrustRow.TrustedPrincipal,
RoleTrustRow.ExternalID,
RoleTrustRow.IsAdmin,
RoleTrustRow.CanPrivEsc})
RoleTrustRow := RoleTrustRow{
RoleARN: aws.ToString(role.roleARN),
RoleName: GetResourceNameFromArn(aws.ToString(role.roleARN)),
TrustedPrincipal: principal,
ExternalID: statement.Condition.StringEquals.StsExternalID,
IsAdmin: role.Admin,
CanPrivEsc: role.CanPrivEsc,
}
body = append(body, []string{
aws.ToString(m.Caller.Account),
RoleTrustRow.RoleARN,
RoleTrustRow.RoleName,
RoleTrustRow.TrustedPrincipal,
RoleTrustRow.ExternalID,
RoleTrustRow.IsAdmin,
RoleTrustRow.CanPrivEsc})
}
}

}

m.sortTrustsTablePerTrustedPrincipal()
Expand Down
13 changes: 9 additions & 4 deletions aws/sdk/apigateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/apigateway"
apiGatewayTypes "github.com/aws/aws-sdk-go-v2/service/apigateway/types"
"github.com/patrickmn/go-cache"
)

type APIGatewayClientInterface interface {
Expand Down Expand Up @@ -66,7 +67,7 @@ func CachedApiGatewayGetRestAPIs(client APIGatewayClientInterface, accountID str
}
PaginationControl = GetRestApis.Position
}

internal.Cache.Set(cacheKey, restAPIs, cache.DefaultExpiration)
return restAPIs, nil
}

Expand All @@ -92,6 +93,7 @@ func CachedApiGatewayGetStages(client APIGatewayClientInterface, accountID strin
return apigateway.GetStagesOutput{}, err
}

internal.Cache.Set(cacheKey, GetStages, cache.DefaultExpiration)
return *GetStages, err
}

Expand Down Expand Up @@ -129,7 +131,7 @@ func CachedApiGatewayGetResources(client APIGatewayClientInterface, accountID st
}
PaginationControl = GetResources.Position
}

internal.Cache.Set(cacheKey, resources, cache.DefaultExpiration)
return resources, nil
}

Expand Down Expand Up @@ -166,7 +168,7 @@ func CachedApiGatewayGetDomainNames(client APIGatewayClientInterface, accountID
}
PaginationControl = GetDomainNames.Position
}

internal.Cache.Set(cacheKey, domainNames, cache.DefaultExpiration)
return domainNames, nil
}

Expand Down Expand Up @@ -204,7 +206,7 @@ func CachedApiGatewayGetBasePathMappings(client APIGatewayClientInterface, accou
}
PaginationControl = GetBasePathMappings.Position
}

internal.Cache.Set(cacheKey, basePathMappings, cache.DefaultExpiration)
return basePathMappings, nil
}

Expand Down Expand Up @@ -233,6 +235,7 @@ func CachedApiGatewayGetMethod(client APIGatewayClientInterface, accountID strin
return apigateway.GetMethodOutput{}, err
}

internal.Cache.Set(cacheKey, GetMethod, cache.DefaultExpiration)
return *GetMethod, nil

}
Expand Down Expand Up @@ -271,6 +274,7 @@ func CachedApiGatewayGetUsagePlans(client APIGatewayClientInterface, accountID s
PaginationControl = GetUsagePlans.Position
}

internal.Cache.Set(cacheKey, usagePlans, cache.DefaultExpiration)
return usagePlans, nil
}

Expand Down Expand Up @@ -309,5 +313,6 @@ func CachedApiGatewayGetUsagePlanKeys(client APIGatewayClientInterface, accountI
PaginationControl = GetUsagePlanKeys.Position
}

internal.Cache.Set(cacheKey, usagePlanKeys, cache.DefaultExpiration)
return usagePlanKeys, nil
}

0 comments on commit 15e0507

Please sign in to comment.