Skip to content

Commit b495377

Browse files
committed
updates
- switch to golang 1.25 - update dependencies - switch from zap logging to slog Signed-off-by: Markus Blaschke <[email protected]>
1 parent 56007be commit b495377

29 files changed

+379
-339
lines changed

.github/workflows/build-docker.yaml

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,16 @@ jobs:
1111
lint:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v6
1515

16-
- name: Set Swap Space
17-
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
18-
with:
19-
swap-size-gb: 12
16+
- name: Setup runner
17+
uses: webdevops/setup-runner@main
2018

21-
- uses: actions/setup-go@v5
22-
with:
23-
go-version-file: 'go.mod'
24-
cache-dependency-path: "go.sum"
25-
check-latest: true
19+
- name: Setup go
20+
uses: webdevops/setup-go@main
2621

2722
- name: Run Golangci lint
28-
uses: golangci/golangci-lint-action@v7
23+
uses: golangci/golangci-lint-action@v9
2924
with:
3025
version: latest
3126
args: --print-resources-usage
@@ -41,21 +36,20 @@ jobs:
4136
target: "final-static"
4237
suffix: ""
4338
latest: "auto"
39+
- Dockerfile: Dockerfile
40+
target: "final-azcli"
41+
suffix: "-azcli"
42+
latest: false
4443

4544
runs-on: ubuntu-latest
4645
steps:
47-
- uses: actions/checkout@v4
46+
- uses: actions/checkout@v6
4847

49-
- name: Set Swap Space
50-
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
51-
with:
52-
swap-size-gb: 12
48+
- name: Setup runner
49+
uses: webdevops/setup-runner@main
5350

54-
- uses: actions/setup-go@v5
55-
with:
56-
go-version-file: 'go.mod'
57-
cache-dependency-path: "go.sum"
58-
check-latest: true
51+
- name: Setup go
52+
uses: webdevops/setup-go@main
5953

6054
- name: Docker meta
6155
id: docker_meta

.github/workflows/ci-docker.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: "ci/docker"
22

33
on: [pull_request, workflow_dispatch]
44

5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
59
jobs:
610
build:
711
uses: ./.github/workflows/build-docker.yaml

.github/workflows/release-assets.yaml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,34 @@ on:
44
release:
55
types: [created]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: false
10+
11+
env:
12+
RELEASE_TAG: ${{ github.ref_name }}
13+
714
jobs:
8-
release:
15+
build:
16+
name: "${{ matrix.task }}"
917
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- task: release-assets
1023
steps:
11-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
1225

13-
- name: Set Swap Space
14-
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
15-
with:
16-
swap-size-gb: 12
26+
- name: Setup runner
27+
uses: webdevops/setup-runner@main
1728

18-
- uses: actions/setup-go@v5
19-
with:
20-
go-version-file: 'go.mod'
21-
cache-dependency-path: "go.sum"
22-
check-latest: true
29+
- name: Setup go
30+
uses: webdevops/setup-go@main
2331

2432
- name: Build
2533
run: |
26-
make release-assets
34+
make "${{ matrix.task }}"
2735
2836
- name: Upload assets to release
2937
uses: svenstaro/upload-release-action@v2
@@ -33,3 +41,4 @@ jobs:
3341
tag: ${{ github.ref }}
3442
overwrite: true
3543
file_glob: true
44+
promote: false

.github/workflows/release-docker.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "release/docker"
22

33
on:
4+
workflow_dispatch: {}
45
push:
56
branches:
67
- 'main'
@@ -9,6 +10,10 @@ on:
910
tags:
1011
- '*.*.*'
1112

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
1217
jobs:
1318
release:
1419
uses: ./.github/workflows/build-docker.yaml

.github/workflows/schedule-docker.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
schedule:
55
- cron: '45 6 * * 1'
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
812
schedule:
913
uses: ./.github/workflows/build-docker.yaml

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#############################################
22
# Build
33
#############################################
4-
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS build
4+
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS build
55

66
RUN apk upgrade --no-cache --force
77
RUN apk add --update build-base make git
@@ -38,7 +38,6 @@ COPY --from=test /app .
3838
USER 1000:1000
3939
ENTRYPOINT ["/azure-auditor"]
4040

41-
4241
#############################################
4342
# final-static
4443
#############################################

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
PROJECT_NAME := $(shell basename $(CURDIR))
22
GIT_TAG := $(shell git describe --dirty --tags --always)
33
GIT_COMMIT := $(shell git rev-parse --short HEAD)
4-
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -extldflags "-static" -s -w
4+
BUILD_DATE := $(shell TZ=UTC date '+%Y-%m-%dT%H:%M:%SZ')
5+
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -X "main.buildDate=$(BUILD_DATE)" -extldflags "-static" -s -w
6+
BUILDFLAGS := -trimpath
57

68
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH)))
79
GOLANGCI_LINT_BIN := $(FIRST_GOPATH)/bin/golangci-lint
@@ -25,13 +27,13 @@ vendor:
2527

2628
.PHONY: build-all
2729
build-all:
28-
GOOS=linux GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o '$(PROJECT_NAME)' .
29-
GOOS=darwin GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o '$(PROJECT_NAME).darwin' .
30-
GOOS=windows GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o '$(PROJECT_NAME).exe' .
30+
GOOS=linux GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' $(BUILDFLAGS) -o '$(PROJECT_NAME)' .
31+
GOOS=darwin GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' $(BUILDFLAGS) -o '$(PROJECT_NAME).darwin' .
32+
GOOS=windows GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' $(BUILDFLAGS) -o '$(PROJECT_NAME).exe' .
3133

3234
.PHONY: build
3335
build:
34-
GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o $(PROJECT_NAME) .
36+
GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' $(BUILDFLAGS) -o $(PROJECT_NAME) .
3537

3638
.PHONY: image
3739
image: image

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ Usage:
2323
azure-auditor [OPTIONS]
2424
2525
Application Options:
26-
--log.debug debug mode [$LOG_DEBUG]
27-
--log.devel development mode [$LOG_DEVEL]
28-
--log.json Switch log output to json format [$LOG_JSON]
26+
--version Show version
27+
--version.template= Version go template, eg {{.Version}}
28+
--log.level=[trace|debug|info|warning|error] Log level (default: info) [$LOG_LEVEL]
29+
--log.format=[logfmt|json] Log format (default: logfmt) [$LOG_FORMAT]
30+
--log.source=[|short|file|full] Show source for every log message (useful for debugging and bug reports) [$LOG_SOURCE]
31+
--log.color=[|auto|yes|no] Enable color for logs [$LOG_COLOR]
32+
--log.time Show log time [$LOG_TIME]
2933
--azure.environment= Azure environment name (default: AZUREPUBLICCLOUD) [$AZURE_ENVIRONMENT]
3034
--azure.tenant= Azure tenant id [$AZURE_TENANT_ID]
3135
--azure.subscription= Azure subscription ID [$AZURE_SUBSCRIPTION_ID]
3236
--azure.tag.inherit= Inherit tags [$AZURE_TAG_INHERIT]
3337
--report.title= Report title [$REPORT_TITLE]
3438
--report.pagination.size=[5|10|25|50|100|250] Report pagination size (default: 50) [$REPORT_PAGINATION_SIZE]
35-
--cron.keytvaultaccesspolicies= Cronjob for KeyVault AccessPolicies report (default: 0 * * * *)
36-
[$CRON_KEYTVAULTACCESSPOLICIES]
39+
--cron.keytvaultaccesspolicies= Cronjob for KeyVault AccessPolicies report (default: 0 * * * *) [$CRON_KEYTVAULTACCESSPOLICIES]
3740
--cron.resourcegroups= Cronjob for ResourceGroups report (default: */30 * * * *) [$CRON_RESOURCEGROUPS]
3841
--cron.resourceproviders= Cronjob for ResourceProviders report (default: 0 * * * *) [$CRON_RESOURCEPROVIDERS]
3942
--cron.roleassignments= Cronjob for RoleAssignments report (default: */5 * * * *) [$CRON_ROLEASSIGNMENTS]

auditor/auditor.azure.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import (
1414
func (auditor *AzureAuditor) getSubscriptionList(ctx context.Context) (list map[string]*armsubscriptions.Subscription) {
1515
list, err := auditor.azure.client.ListCachedSubscriptions(ctx)
1616
if err != nil {
17-
auditor.Logger.Panic(err)
17+
auditor.Logger.Panic(err.Error())
1818
}
1919
return list
2020
}
2121

2222
func (auditor *AzureAuditor) getResourceGroupList(ctx context.Context, subscription *armsubscriptions.Subscription) (list map[string]*armresources.ResourceGroup) {
2323
list, err := auditor.azure.client.ListResourceGroups(ctx, *subscription.SubscriptionID)
2424
if err != nil {
25-
auditor.Logger.Panic(err)
25+
auditor.Logger.Panic(err.Error())
2626
}
2727
return list
2828
}
@@ -42,14 +42,14 @@ func (auditor *AzureAuditor) getResourceList(ctx context.Context, subscription *
4242

4343
client, err := armresources.NewClient(*subscription.SubscriptionID, auditor.azure.client.GetCred(), nil)
4444
if err != nil {
45-
auditor.Logger.Panic(err)
45+
auditor.Logger.Panic(err.Error())
4646
}
4747
pager := client.NewListPager(nil)
4848

4949
for pager.More() {
5050
result, err := pager.NextPage(ctx)
5151
if err != nil {
52-
auditor.Logger.Panic(err)
52+
auditor.Logger.Panic(err.Error())
5353
}
5454

5555
for _, item := range result.Value {
@@ -81,14 +81,14 @@ func (auditor *AzureAuditor) getRoleDefinitionList(ctx context.Context, subscrip
8181

8282
client, err := armauthorization.NewRoleDefinitionsClient(auditor.azure.client.GetCred(), nil)
8383
if err != nil {
84-
auditor.Logger.Panic(err)
84+
auditor.Logger.Panic(err.Error())
8585
}
8686

8787
pager := client.NewListPager(*subscription.ID, nil)
8888
for pager.More() {
8989
result, err := pager.NextPage(ctx)
9090
if err != nil {
91-
auditor.Logger.Panic(err)
91+
auditor.Logger.Panic(err.Error())
9292
}
9393

9494
for _, item := range result.Value {

auditor/auditor.enrich.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (auditor *AzureAuditor) enrichAzureObjectsWithMsGraphPrincipals(ctx context
152152
if len(principalIdList) > 0 {
153153
principalObjectMap, err := auditor.azure.msGraph.LookupPrincipalID(ctx, principalIdList...)
154154
if err != nil {
155-
auditor.Logger.Panic(err)
155+
auditor.Logger.Panic(err.Error())
156156
}
157157

158158
for key, row := range *list {

0 commit comments

Comments
 (0)