Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gosec to asset-syncer #4989

Merged
merged 2 commits into from
Jul 1, 2022
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/asset-syncer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ COPY go.mod go.sum ./
COPY pkg pkg
COPY cmd cmd
ARG VERSION

ARG GOSEC_VERSION="2.12.0"
RUN curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v$GOSEC_VERSION

# Run gosec to detect any security-related error at build time
RUN gosec ./cmd/asset-syncer/...

# With the trick below, Go's build cache is kept between builds.
# https://github.com/golang/go/issues/27719#issuecomment-514747274
RUN --mount=type=cache,target=/go/pkg/mod \
Expand Down
13 changes: 9 additions & 4 deletions cmd/asset-syncer/server/postgresql_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ func newPGManager(config dbutils.Config, globalReposNamespace string) (assetMana
// imported into the database as fast as possible. E.g. we want all icons for
// charts before fetching readmes for each chart and version pair.
func (m *postgresAssetManager) Sync(repo models.Repo, charts []models.Chart) error {
m.InitTables()

err := m.InitTables()
if err != nil {
return err
}
// Ensure the repo exists so FK constraints will be met.
_, err := m.EnsureRepoExists(repo.Namespace, repo.Name)
_, err = m.EnsureRepoExists(repo.Namespace, repo.Name)
if err != nil {
return err
}
Expand All @@ -61,7 +63,10 @@ func (m *postgresAssetManager) LastChecksum(repo models.Repo) string {
var lastChecksum string
row := m.DB.QueryRow(fmt.Sprintf("SELECT checksum FROM %s WHERE name = $1 AND namespace = $2", dbutils.RepositoryTable), repo.Name, repo.Namespace)
if row != nil {
row.Scan(&lastChecksum)
err := row.Scan(&lastChecksum)
if err != nil {
return ""
}
}
return lastChecksum
}
Expand Down