Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 38 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Weekly dependency update PRs. The github-actions ecosystem also keeps the
# workflows' full-SHA action pins current: it updates the SHA and its trailing
# version comment together, which is what makes pinning to a commit
# maintainable rather than a slow drift into stale actions.
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
day: monday
commit-message:
prefix: deps
# SHIELD links the AWS, Google, Azure and Docker SDKs, so ungrouped
# updates open a queue of PRs every week and each one costs a full CI
# chain on the lab runners. One PR carries every patch and minor bump;
# majors stay separate, since those want reading.
groups:
go-minor-patch:
update-types:
- minor
- patch

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
commit-message:
prefix: ci

- package-ecosystem: docker
directory: /
schedule:
interval: weekly
day: monday
commit-message:
prefix: docker
265 changes: 265 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
name: CI

on:
push:
branches: [develop, main]
pull_request:
branches: [develop, main]

permissions:
contents: read

# The lab runners are a small, shared pool, so a superseded pull-request run
# would keep them busy long after its result stopped mattering. Cancel it when
# new commits arrive, and never cancel a run on develop or main.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

# Each lab runner VM hosts four jobs on eight cores. Go sizes its build
# parallelism from the host core count, so without this every job fans out as
# if it owned the machine and four of them together exhaust the VM's memory.
# Runner-level env does not cross into container jobs; workflow env is part of
# the job context, which the runner does carry in.
env:
GOMAXPROCS: 2

jobs:
# Every job runs in a golang container. The self-hosted runner host is
# deliberately minimal, and mixing host jobs with container jobs leaves the
# shared workspace owned by two different uids (the host runner user and
# container root), which breaks checkout cleanup and trips git's
# dubious-ownership guard.
#
# The "Trust the checkout" step writes safe.directory at --system level
# (/etc/gitconfig). The checkout action writes it under its own HOME, which
# the shell steps in the container do not share, so git run by go build's
# VCS stamping would otherwise exit 128 on the runner-user-owned .git.
#
# Actions are pinned to full commit SHAs, since tags move and these jobs run
# on a lab runner; Dependabot's github-actions ecosystem keeps the pins
# current. persist-credentials is off everywhere: no job pushes, and the
# workspace survives between jobs on this runner.
#
# timeout-minutes is set on every job, because a hung job would otherwise
# hold a runner for GitHub's six-hour default.
#
# The Go module and build caches are host directories bind-mounted into each
# container rather than the Actions cache service. The container filesystem
# is fresh every job but the runner is persistent, so fetching and unpacking
# a multi-GB cache.tzst costs more than the build it saves, and it untars
# over Go's read-only module cache. setup-go's own cache stays off for the
# same reason. The mounts live outside _work, so the runner's workspace
# reclaim hook leaves them alone. GOCACHE is set explicitly because the
# runner overrides HOME to /github/home inside the container, which lives
# under _work/_temp and is wiped between jobs.
lint:
name: Lint
runs-on: self-hosted
container:
image: golang:1.27.1
volumes:
- /home/runner/gha-container-cache/go:/go
- /home/runner/gha-container-cache/go-build:/root/.cache/go-build
env:
GOCACHE: /root/.cache/go-build
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Trust the checkout despite mixed file owners
run: git config --system --add safe.directory "$GITHUB_WORKSPACE"

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27.1'
# The mounted /go volume is the module cache; the action's own cache
# would restore a second copy over it and fail on tar.
cache: false

# gofmt is checked over the tracked sources only. The vendor tree is
# third-party code we do not reformat, and `make format` would rewrite
# files rather than report them.
- name: Check gofmt
run: |
unformatted=$(gofmt -l $(git ls-files '*.go' | grep -v '^vendor/'))
if [ -n "$unformatted" ]; then
echo "These files need gofmt:"
echo "$unformatted"
exit 1
fi

- name: Run go vet
run: go vet -mod=vendor ./...

test:
name: Test
runs-on: self-hosted
container:
image: golang:1.27.1
volumes:
- /home/runner/gha-container-cache/go:/go
- /home/runner/gha-container-cache/go-build:/root/.cache/go-build
env:
GOCACHE: /root/.cache/go-build
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Trust the checkout despite mixed file owners
run: git config --system --add safe.directory "$GITHUB_WORKSPACE"

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27.1'
cache: false

# `make go-tests` builds the daemon, agent, schema, crypt and report
# binaries first and then runs `go test -race` with the repository root
# and bin/ on PATH. The agent suite shells out to shield-pipe, so the
# binaries have to exist before the tests run; calling `go test` on its
# own leaves five agent specs failing with exit status 127.
- name: Run unit tests with the race detector
run: make go-tests

build:
name: Build
runs-on: self-hosted
container:
image: golang:1.27.1
volumes:
- /home/runner/gha-container-cache/go:/go
- /home/runner/gha-container-cache/go-build:/root/.cache/go-build
env:
GOCACHE: /root/.cache/go-build
timeout-minutes: 30
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Trust the checkout despite mixed file owners
run: git config --system --add safe.directory "$GITHUB_WORKSPACE"

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27.1'
cache: false

# The repository vendors its dependencies, so the build must not reach
# the network. `go mod verify` checks the module cache against go.sum,
# and building with -mod=vendor proves the vendor tree is complete and
# consistent with go.mod.
- name: Verify vendored dependencies
run: |
go mod verify
go build -mod=vendor ./...

- name: Build every binary and plugin
run: make build

plugin-tests:
name: Plugin Tests
runs-on: self-hosted
container:
image: golang:1.27.1
volumes:
- /home/runner/gha-container-cache/go:/go
- /home/runner/gha-container-cache/go-build:/root/.cache/go-build
env:
GOCACHE: /root/.cache/go-build
timeout-minutes: 30
needs: [lint, test]
# Eight of the 134 plugin specs in t/plugins already fail on develop: they
# assert the compact "USAGE: ..." help that the plugin framework printed
# for `-h` before it was changed to print the long help for both flags.
# Deciding whether the framework or the expectations are wrong is a
# separate change, so this job reports without blocking a merge. Drop
# continue-on-error once those eight are settled.
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Trust the checkout despite mixed file owners
run: git config --system --add safe.directory "$GITHUB_WORKSPACE"

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27.1'
cache: false

- name: Run plugin tests
run: make plugin-tests

security:
name: Security Scan
runs-on: self-hosted
container:
image: golang:1.27.1
volumes:
- /home/runner/gha-container-cache/go:/go
- /home/runner/gha-container-cache/go-build:/root/.cache/go-build
env:
GOCACHE: /root/.cache/go-build
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Trust the checkout despite mixed file owners
run: git config --system --add safe.directory "$GITHUB_WORKSPACE"

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.27.1'
cache: false

# govulncheck reports only the advisories whose vulnerable symbols this
# code actually reaches, so it is the gate that can stay red-means-broken
# rather than red-means-someone-published-a-CVE.
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
"$(go env GOPATH)/bin/govulncheck" ./...

# Installed from the pinned release rather than through trivy-action: the
# action's own installer resolves "latest" unless pinned twice, and a
# plain binary drop keeps this job's moving parts visible.
- name: Install trivy
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh \
| sh -s -- -b /usr/local/bin v0.74.0

# Gating on HIGH and CRITICAL only, so an unfixable low-severity advisory
# cannot hold CI red with nothing to remediate. The vendor tree is
# skipped for misconfiguration scanning: it carries upstream projects'
# own Dockerfiles, which we neither build nor ship. Suppressions with
# their justifications live in .trivyignore.
- name: Scan repository
run: >-
trivy fs
--scanners vuln,secret,misconfig
--severity HIGH,CRITICAL
--exit-code 1
--skip-dirs .git
--skip-dirs vendor
--skip-dirs tmp
.
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Trivy suppressions. Every entry names the finding and the reason we accept
# it; anything not listed here has to be fixed rather than muted.

# DS-0002 -- "Specify at least 1 USER command in Dockerfile".
#
# The SHIELD image's entrypoint scripts (init/core, init/agent) run as root
# on purpose: they lay down the data and vault-data directories, chown them
# to vcap, and hand off. The image already creates the unprivileged vcap
# account for the daemon itself, so a USER line at the top would only break
# the setup that grants that account its directories. The demo and webdav
# images under docker/ are local development fixtures that never leave a
# laptop or a lab, and neither one is published as a runtime dependency.
DS-0002
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ARG UBUNTU_RELEASE=noble
ARG GO_VERSION=1.26.1
ARG GO_VERSION=1.27.1

FROM ubuntu:${UBUNTU_RELEASE} AS build
ARG GO_VERSION
ARG TARGETARCH
ARG VERSION=local

RUN apt-get update \
&& apt-get install -y bzip2 gzip unzip curl git make gcc libc6-dev openssh-client ca-certificates \
&& apt-get install -y --no-install-recommends bzip2 gzip unzip curl git make gcc libc6-dev openssh-client ca-certificates \
&& curl -sL https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz | tar -C /usr/local -xzf - \
&& rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -46,7 +46,7 @@ RUN curl -sLo /tmp/vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSIO
FROM ubuntu:${UBUNTU_RELEASE}

RUN apt-get update \
&& apt-get install -y curl netcat-openbsd openssh-client \
&& apt-get install -y --no-install-recommends curl netcat-openbsd openssh-client \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -r -m -s /bin/bash vcap

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/starkandwayne/shield.svg)](https://travis-ci.org/starkandwayne/shield)
[![CI](https://github.com/shieldproject/shield/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/shieldproject/shield/actions/workflows/ci.yml)

S.H.I.E.L.D. Data Protection
============================
Expand Down
2 changes: 0 additions & 2 deletions db/tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ var _ = Describe("tenant Management", func() {
Tenant3 = &Tenant{UUID: "b1d6eeeb-1235-4c93-8800-f5c44ee50f1b"}
AdminUser = &User{UUID: "4cedd497-9af4-484d-a0b2-b79bdb46223f"}
OtherUser = &User{UUID: "e0122b8b-0ca7-480e-a5d8-40aab7e5e8cb"}
AdminUser = AdminUser
OtherUser = OtherUser

db, err = Database(
// need a target1
Expand Down
Loading
Loading