Skip to content

Commit 61d87b5

Browse files
Merge pull request #457 from step-security/cherry/armour-update
Cherry/armour update
2 parents e2bfba3 + e84ba7c commit 61d87b5

File tree

13 files changed

+85
-19
lines changed

13 files changed

+85
-19
lines changed

.github/workflows/int.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,22 @@ jobs:
3737
go mod vendor
3838
3939
- run: sudo go test -v
40-
- run: go build -ldflags="-s -w" -o ./agent
40+
41+
- uses: goreleaser/goreleaser-action@5df302e5e9e4c66310a6b6493a8865b12c555af2
42+
with:
43+
distribution: goreleaser
44+
version: latest
45+
args: release --snapshot --clean --config releasers/int.yml
46+
4147
- name: Configure aws credentials
4248
uses: aws-actions/configure-aws-credentials@ea7b857d8a33dc2fb4ef5a724500044281b49a5e
4349
with:
4450
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
4551
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4652
aws-region: us-west-2
47-
- run: aws s3 cp ./agent s3://step-security-agent/refs/heads/int/agent --acl public-read
53+
54+
55+
- run: aws s3 cp ./dist/agent_linux_amd64_v1/agent s3://step-security-agent/refs/heads/int/agent --acl public-read
4856
- name: Integration test
4957
uses: docker://ghcr.io/step-security/integration-test/int:latest
5058
env:

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ builds:
1818
flags:
1919
- -trimpath
2020
ldflags:
21-
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date=123
21+
- -s -w -X main.ReleaseTag={{.Tag}} -X main.ReleaseBranch={{.Branch}} -X main.ReleaseCommit={{.FullCommit}}
2222

2323

2424
# Optionally override the matrix generation and specify only the final list of targets.

agent_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ func TestRun(t *testing.T) {
159159
httpmock.RegisterResponder("GET", "https://apiurl/v1/github/owner/repo/actions/subscription",
160160
httpmock.NewStringResponder(403, ""))
161161

162+
httpmock.RegisterResponder("GET", "https://apiurl/v1/global-feature-flags?agent_type=agent-oss&version=",
163+
httpmock.NewStringResponder(200, `{"agent_type":"agent-oss","enable_armour":false}`))
164+
162165
tests := []struct {
163166
name string
164167
args args

apiclient.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"fmt"
77
"io"
88
"net/http"
9+
"net/url"
10+
"path"
911
"time"
1012
)
1113

@@ -107,28 +109,43 @@ func (apiclient *ApiClient) getSubscriptionStatus(repo string) bool {
107109

108110
func (apiclient *ApiClient) getGlobalFeatureFlags() GlobalFeatureFlags {
109111

110-
url := fmt.Sprintf("%s/global-feature-flags?agent_type=%s", apiclient.APIURL, AgentTypeGitHubHosted)
112+
u, err := url.Parse(apiclient.APIURL)
113+
if err != nil {
114+
return GlobalFeatureFlags{}
115+
}
116+
117+
u.Path = path.Join(u.Path, "global-feature-flags")
118+
119+
// Add query parameters
120+
values := url.Values{}
121+
values.Add("agent_type", AgentTypeOSS)
122+
values.Add("version", ReleaseTag) // v1.3.6
123+
u.RawQuery = values.Encode()
111124

112-
req, err := http.NewRequest(http.MethodGet, url, nil)
125+
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
113126

114127
if err != nil {
128+
fmt.Println("Error creating request:", err)
115129
return GlobalFeatureFlags{}
116130
}
117131

118132
resp, err := apiclient.Client.Do(req)
119133

120134
if err != nil {
135+
fmt.Println("Error sending request:", err)
121136
return GlobalFeatureFlags{}
122137
}
123138

124139
body, err := io.ReadAll(resp.Body)
125140
if err != nil {
141+
fmt.Println("Error reading response body:", err)
126142
return GlobalFeatureFlags{}
127143
}
128144

129145
var globalFeatureFlags GlobalFeatureFlags
130146
err = json.Unmarshal(body, &globalFeatureFlags)
131147
if err != nil {
148+
fmt.Println("Error unmarshalling response body:", err)
132149
return GlobalFeatureFlags{}
133150
}
134151

buildinfo.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import "fmt"
4+
5+
// filled through ldflags
6+
var (
7+
ReleaseTag = ""
8+
ReleaseBranch = ""
9+
ReleaseCommit = ""
10+
)
11+
12+
func LogBuildInfo() {
13+
WriteLog(fmt.Sprintf("[buildInfo] tag=%s commit=%s branch=%s \n", ReleaseTag, ReleaseCommit, ReleaseBranch))
14+
}

common.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ func getPidsOfInterest() []uint32 {
1818
// our process
1919
out = append(out, uint32(os.Getpid()))
2020

21-
// systemd-resolved
22-
systemdResolvePid, _ := pidOf("systemd-resolved")
23-
24-
out = append(out, uint32(systemdResolvePid))
25-
2621
return out
2722
}
2823

@@ -47,9 +42,6 @@ func getFilesOfInterest() []string {
4742
func getProcFilesOfInterest() []string {
4843
out := []string{}
4944

50-
// our memory files
51-
out = append(out, getProcMemFiles(uint64(os.Getpid()))...)
52-
5345
// runner worker memory files
5446
runnerWorker, _ := pidOf("Runner.Worker")
5547
out = append(out, getProcMemFiles(runnerWorker)...)
@@ -94,7 +86,6 @@ func getProcMemFiles(pid uint64) []string {
9486
}
9587

9688
out = []string{
97-
fmt.Sprintf("/proc/%d/maps", pid),
9889
fmt.Sprintf("/proc/%d/mem", pid),
9990
}
10091

global_feature_flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
AgentTypeGitHubHosted = "githubhosted"
10+
AgentTypeOSS = "agent-oss"
1111
)
1212

1313
type GlobalFeatureFlags struct {
@@ -51,7 +51,7 @@ func (manager *GlobalFeatureFlagManager) refresh() error {
5151
defer manager.mutex.Unlock()
5252

5353
flags := manager.apiClient.getGlobalFeatureFlags()
54-
54+
WriteLog(fmt.Sprintf("Global feature flags: %+v", flags))
5555
manager.flags = flags
5656
return nil
5757
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/jarcoal/httpmock v1.3.0
1111
github.com/miekg/dns v1.1.53
1212
github.com/pkg/errors v0.9.1
13-
github.com/step-security/armour v1.0.1
13+
github.com/step-security/armour v1.0.4
1414
)
1515

1616
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
102102
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
103103
github.com/step-security/armour v1.0.1 h1:+Lae8o/cbSV0HFD4wKhx4mHnQCTEJ8ndRN0gfmu1t3I=
104104
github.com/step-security/armour v1.0.1/go.mod h1:I6pTEysb5fd3Cc79tvCMVp70RqhvMYbawfoq5Gz0cPI=
105+
github.com/step-security/armour v1.0.4 h1:bTtvS4A9TTG83sSXW/+nno9cQOgqaueAedGdunE1eaY=
106+
github.com/step-security/armour v1.0.4/go.mod h1:I6pTEysb5fd3Cc79tvCMVp70RqhvMYbawfoq5Gz0cPI=
105107
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
106108
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
107109
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import (
1313
const agentConfigFilePath = "agent.json"
1414

1515
func main() {
16+
17+
LogBuildInfo()
18+
1619
ctx := context.Background()
1720
ctx, cancel := context.WithCancel(ctx)
1821

0 commit comments

Comments
 (0)