Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
pull-requests: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with:
disable-sudo: true
egress-policy: block
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ jobs:
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
- uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really odd one. actions/checkout@629c2de doesn't resolve. But the workflow is able to use this sha. It appears to be a sha that references a replaced v2 tag:

Tagger: eric sciple <ericsciple@users.noreply.github.com>
Date:   Tue Nov 2 12:49:38 2021 -0500

Update v2 tag

commit ec3a7ce113134d7a93b817d10a8272cb61118579

actions/checkout@ec3a7ce

uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@5f532563584d71fdef14ee64d17bafb34f751ce5
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was v1.0.26

uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the latest codeql-action action (as opposed to another artifact that the repository ships): https://github.com/github/codeql-action/releases/tag/v3.28.15

with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@5f532563584d71fdef14ee64d17bafb34f751ce5
uses: github/codeql-action/autobuild@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -70,4 +70,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@5f532563584d71fdef14ee64d17bafb34f751ce5
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit

Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,38 @@ env:
GOPRIVATE: github.com/step-security
jobs:
integration-test:
if: github.event.repository.fork == false
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@v2
- uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with:
go-version: 1.24.1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is greater than 1.16 where ioutil is deprecated, see https://pkg.go.dev/io/ioutil


- name: Configure .netrc
env:
PAT: ${{ secrets.PAT }}
run: |
if [[ ! -e "~/.netrc" ]]; then
touch ~/.netrc
fi
printf "machine github.com login stepsecurity-infra-bot password ${{ secrets.PAT }}" >>~/.netrc
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice is to not use ${{ ... }} inside a run: statement and instead favor env variables.

printf "machine github.com login stepsecurity-infra-bot password $PAT" >>~/.netrc

- name: Create go vendor dir
run: |
go mod vendor

- run: sudo go test -v
- run: go build -ldflags="-s -w" -o ./agent
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@ea7b857d8a33dc2fb4ef5a724500044281b49a5e
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ env:
GOPRIVATE: github.com/step-security
jobs:
release:
if: github.event.repository.fork == false
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
- uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
with:
allowed-endpoints:
api.github.com:443
Expand All @@ -25,26 +26,28 @@ jobs:
storage.googleapis.com:443
uploads.github.com:443
- name: Checkout
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version: 1.24.1

- name: Configure .netrc
env:
PAT: ${{ secrets.PAT }}
run: |
if [[ ! -e "~/.netrc" ]]; then
touch ~/.netrc
fi
printf "machine github.com login stepsecurity-infra-bot password ${{ secrets.PAT }}" >>~/.netrc
printf "machine github.com login stepsecurity-infra-bot password $PAT" >>~/.netrc


- name: Create go vendor dir
run: |
go mod vendor


- uses: goreleaser/goreleaser-action@5df302e5e9e4c66310a6b6493a8865b12c555af2
- uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with:
distribution: goreleaser
version: latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # tag=v1.0.26
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
with:
sarif_file: results.sarif
11 changes: 7 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,31 @@ env:

jobs:
test:
if: github.event.repository.fork == false
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version: 1.24.1

- name: Configure .netrc
env:
PAT: ${{ secrets.PAT }}
run: |
if [[ ! -e "~/.netrc" ]]; then
touch ~/.netrc
fi
printf "machine github.com login stepsecurity-infra-bot password ${{ secrets.PAT }}" >>~/.netrc
printf "machine github.com login stepsecurity-infra-bot password $PAT" >>~/.netrc

- name: Create go vendor dir
run: |
go mod vendor

- name: Run coverage
run: sudo CI=true go test -race -coverprofile=coverage.txt -covermode=atomic
- uses: codecov/codecov-action@40a12dcee2df644d47232dde008099a3e9e4f865
- uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"encoding/json"
"io/ioutil"
"os"
"strconv"
"strings"

Expand Down Expand Up @@ -50,7 +50,7 @@ type configFile struct {
// init reads the config file for the agent and initializes config settings
func (c *config) init(configFilePath string) error {
var configFile configFile
data, err := ioutil.ReadFile(configFilePath)
data, err := os.ReadFile(configFilePath)
if err != nil {
return errors.Wrap(err, "failed to read config file")
}
Expand Down
3 changes: 1 addition & 2 deletions dnsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path"
Expand All @@ -30,7 +29,7 @@ const (

func updateDockerConfig(configPath string) error {

data, err := ioutil.ReadFile(configPath)
data, err := os.ReadFile(configPath)
if err != nil && !errors.Is(err, os.ErrNotExist) {
return errors.Wrap(err, "failed to read config file")
}
Expand Down
9 changes: 4 additions & 5 deletions dnsconfig_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"log"
"os"
"path"
Expand All @@ -10,7 +9,7 @@ import (
)

func createTempFileWithContents(content string) string {
file, err := ioutil.TempFile("", "*.json")
file, err := os.CreateTemp("", "*.json")
if err != nil {
log.Fatal(err)
}
Expand All @@ -28,7 +27,7 @@ func Test_updateDockerConfig(t *testing.T) {
configPath string
}
tmpFileName := createTempFileWithContents("{ \"cgroup-parent\": \"/actions_job\"}")
mockDockerConfigPath, err := ioutil.TempDir("", "")
mockDockerConfigPath, err := os.MkdirTemp("", "")
if err != nil {
log.Fatal(err)
}
Expand All @@ -54,7 +53,7 @@ func Test_updateDockerConfig(t *testing.T) {
if err := updateDockerConfig(tt.args.configPath); (err != nil) != tt.wantErr {
t.Errorf("updateDockerConfig() error = %v, wantErr %v", err, tt.wantErr)
}
content, err := ioutil.ReadFile(tt.args.configPath)
content, err := os.ReadFile(tt.args.configPath)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -87,7 +86,7 @@ func Test_writeResolveConfig(t *testing.T) {
if err := writeResolveConfig(tt.args.configPath); (err != nil) != tt.wantErr {
t.Errorf("writeResolveConfig() error = %v, wantErr %v", err, tt.wantErr)
}
content, err := ioutil.ReadFile(tt.args.configPath)
content, err := os.ReadFile(tt.args.configPath)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions dnsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math"
"net/http"
"strings"
Expand Down Expand Up @@ -141,7 +141,7 @@ func (proxy *DNSProxy) ResolveDomain(domain string) (*Answer, error) {

defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)

if err != nil {
return nil, fmt.Errorf("error in response from dns.google %v", err)
Expand Down
5 changes: 2 additions & 3 deletions eventhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"net"
"os"
"path"
Expand Down Expand Up @@ -153,7 +152,7 @@ func printContainerInfo(pid, ppid string) {
}

cgroupPath := fmt.Sprintf("/proc/%s/cgroup", pid)
content, err := ioutil.ReadFile(cgroupPath)
content, err := os.ReadFile(cgroupPath)
if err != nil {
WriteLog(fmt.Sprintf("cgroup not found %v", err))
} else {
Expand Down Expand Up @@ -213,7 +212,7 @@ func (eventHandler *EventHandler) HandleEvent(event *Event) {
}

func GetContainerIdByPid(cgroupPath string) string {
content, err := ioutil.ReadFile(cgroupPath)
content, err := os.ReadFile(cgroupPath)
if err != nil {
// WriteLog(fmt.Sprintf("error reading cgrouppath: %s : %v", cgroupPath, err))
return ""
Expand Down
3 changes: 1 addition & 2 deletions procmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main
import (
"fmt"

"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -177,7 +176,7 @@ func (p *ProcessMonitor) receive(r *libaudit.AuditClient) error {

func getParentProcessId(pid string) (int, error) {
statPath := fmt.Sprintf("/proc/%s/stat", pid)
dataBytes, err := ioutil.ReadFile(statPath)
dataBytes, err := os.ReadFile(statPath)
if err != nil {
return -1, err
}
Expand Down