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

Vulns #1009

Closed
wants to merge 31 commits into from
Closed

Vulns #1009

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f916ad6
Modify logging to support logrus
kumaya Sep 12, 2018
2513950
Modify logging to support logrus
kumaya Sep 18, 2018
f6ccfd4
Merge branch 'master' of https://github.com/golang-migrate/migrate
kumaya Sep 18, 2018
24a850c
Merge branch 'master' of https://github.com/golang-migrate/migrate
kumaya Sep 18, 2018
4499bdf
Enable configuration
kumaya Sep 14, 2018
2ed505f
Merge pull request #3 from kumaya/config
kumaya Oct 3, 2018
adeea01
Configuration support for database string
kumaya Oct 3, 2018
49df9a4
Merge pull request #4 from kumaya/dsn
kumaya Oct 3, 2018
1875527
Update README.md
kumaya Oct 9, 2018
aa78373
Merge branch 'master' of https://github.com/golang-migrate/migrate
kumaya Oct 15, 2018
8a93a8f
Merge pull request #5 from kumaya/master
kumaya Oct 15, 2018
b200546
Update go and alpine versions (#6)
Calebjh Apr 13, 2021
5564ef4
Add Jenkinsfile (#7)
Calebjh Apr 14, 2021
079cf15
Fix test issues
Calebjh Apr 15, 2021
577e929
Skip tests, just build
Calebjh Apr 15, 2021
8e2cb3a
Docker credentials around build, too
Calebjh Apr 15, 2021
2299517
Only push to harbor
Calebjh Apr 15, 2021
c2c9739
URL escape password and username on connection strings (#10)
Calebjh Sep 24, 2021
b912ce7
Merge branch 'master' of github.com:golang-migrate/migrate into ib
kumaya Nov 24, 2021
418501b
merge upstream
daniel-garcia Jul 12, 2022
8445c30
add hotload support
daniel-garcia Jul 14, 2022
f1ec28e
add hotload support (#15)
daniel-garcia Jul 14, 2022
b23a55e
build in ib-branch
daniel-garcia Jul 14, 2022
2786533
Merge branch 'hotload' into ib
daniel-garcia Jul 14, 2022
2d48d39
import fsync
daniel-garcia Jul 15, 2022
f746be2
Upgrade alpine 3.13 -> 3.18 (#21)
ychen-bloxer Oct 13, 2023
31fc03e
adding pgx as the supported hotload base driver (#26)
Gowdasupriya Nov 30, 2023
f83486d
removing the pgx register in migrate (#27)
Gowdasupriya Dec 1, 2023
c441785
Hotload support (#31)
daniel-garcia Dec 8, 2023
d6166ab
resolved upstream conflicts in go.*
daniel-garcia Dec 8, 2023
b82c168
patch vulns
daniel-garcia Dec 8, 2023
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
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM golang:1.20-alpine3.18 AS builder
FROM golang:1.21.5-alpine3.18 AS builder
ARG VERSION

RUN apk add --no-cache git gcc musl-dev make

WORKDIR /go/src/github.com/golang-migrate/migrate
WORKDIR /go/src/github.com/infobloxopen/migrate

ENV GO111MODULE=on

Expand All @@ -17,9 +17,8 @@ RUN make build-docker

FROM alpine:3.18

RUN apk add --no-cache ca-certificates

COPY --from=builder /go/src/github.com/golang-migrate/migrate/build/migrate.linux-386 /usr/local/bin/migrate
COPY --from=builder /go/src/github.com/infobloxopen/migrate/cmd/migrate/config /cli/config/
COPY --from=builder /go/src/github.com/infobloxopen/migrate/build/migrate.linux-386 /usr/local/bin/migrate
RUN ln -s /usr/local/bin/migrate /migrate

ENTRYPOINT ["migrate"]
Expand Down
68 changes: 68 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

// This library defines the isPrBuild, prepareBuild and finalizeBuild methods
@Library('jenkins.shared.library') _

pipeline {
agent {
label 'ubuntu_docker_label'
}
tools {
go "Go 1.20"
}
options {
checkoutToSubdirectory('src/github.com/infobloxopen/migrate')
}
environment {
GOPATH = "$WORKSPACE"
DIRECTORY = "src/github.com/infobloxopen/migrate"
}

stages {
stage("Setup") {
steps {
// prepareBuild is one of the Secure CICD helper methods
prepareBuild()
}
}
stage("Unit Tests") {
steps {
dir("$DIRECTORY") {
// sh "make test"
}
}
}
stage("Build Image") {
// only build images on trunk builds. An alternate approach
// when { branch 'main' } or when { anyOf { branch "main", branch "develop", "ib" } }
when {
expression { ! isPrBuild() }
}
steps {
withDockerRegistry([credentialsId: "${env.JENKINS_DOCKER_CRED_ID}", url: ""]) {
dir("$DIRECTORY") {
sh "make build"
}
}
}
}
}
post {
success {
// finalizeBuild is one of the Secure CICD helper methods
dir("$DIRECTORY") {
finalizeBuild(
sh(
script: 'make list-of-images',
returnStdout: true
)
)
}
}
cleanup {
dir("$DIRECTORY") {
sh "make clean || true"
}
cleanWs()
}
}
}
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SOURCE ?= file go_bindata github github_ee bitbucket aws_s3 google_cloud_storage godoc_vfs gitlab
DATABASE ?= postgres mysql redshift cassandra spanner cockroachdb yugabytedb clickhouse mongodb sqlserver firebird neo4j pgx pgx5
DATABASE_TEST ?= $(DATABASE) sqlite sqlite3 sqlcipher
VERSION ?= $(shell git describe --tags 2>/dev/null | cut -c 2-)
BUILD_NUMBER ?= 0
VERSION ?= $(shell git describe --tags --long --dirty=-unsupported 2>/dev/null | cut -c 2-)-j$(BUILD_NUMBER)
TEST_FLAGS ?=
REPO_OWNER ?= $(shell cd .. && basename "$$(pwd)")
COVERAGE_DIR ?= .coverage
Expand All @@ -24,6 +25,17 @@ build-cli: clean
cd ./cli/build && shasum -a 256 * > sha256sum.txt
cat ./cli/build/sha256sum.txt

build:
docker build --pull --build-arg VERSION=$(VERSION) . -t infoblox/migrate -t infoblox/migrate:$(VERSION)

docker-push:
docker push infoblox/migrate:$(VERSION)

show-image-version:
echo $(VERSION)

list-of-images:
@echo "infoblox/migrate:$(VERSION)"

clean:
-rm -r ./cli/build
Expand Down Expand Up @@ -117,4 +129,3 @@ endef

SHELL = /bin/sh
RAND = $(shell echo $$RANDOM)

4 changes: 3 additions & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import "github.com/golang-migrate/migrate/v4/internal/cli"
import (
"github.com/golang-migrate/migrate/v4/internal/cli"
)

// Deprecated, please use cmd/migrate
func main() {
Expand Down
1 change: 1 addition & 0 deletions cmd/migrate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
migrate
38 changes: 38 additions & 0 deletions cmd/migrate/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import "github.com/spf13/pflag"

const (
// configuration defaults support local development (i.e. "go run ...")
defaultDatabaseDSN = ""
defaultDatabaseDriver = "postgres"
defaultDatabaseAddress = "0.0.0.0:5432"
defaultDatabaseName = ""
defaultDatabaseUser = "postgres"
defaultDatabasePassword = "postgres"
defaultDatabaseSSL = "disable"
defaultConfigDirectory = "/cli/config"
)

var (
// define flag overrides
flagHelp = pflag.Bool("help", false, "Print usage")
flagVersion = pflag.String("version", Version, "Print version")
flagLoggingVerbose = pflag.Bool("verbose", true, "Print verbose logging")
flagPrefetch = pflag.Uint("prefetch", 10, "Number of migrations to load in advance before executing")
flaglockTimeout = pflag.Uint("lock-timeout", 15, "Allow N seconds to acquire database lock")

flagDatabaseDSN = pflag.String("database.dsn", defaultDatabaseDSN, "database connection string")
flagDatabaseDriver = pflag.String("database.driver", defaultDatabaseDriver, "database driver")
flagDatabaseAddress = pflag.String("database.address", defaultDatabaseAddress, "address of the database")
flagDatabaseName = pflag.String("database.name", defaultDatabaseName, "name of the database")
flagDatabaseUser = pflag.String("database.user", defaultDatabaseUser, "database username")
flagDatabasePassword = pflag.String("database.password", defaultDatabasePassword, "database password")
flagDatabaseSSL = pflag.String("database.ssl", defaultDatabaseSSL, "database ssl mode")

flagSource = pflag.String("source", "", "Location of the migrations (driver://url)")
flagPath = pflag.String("path", "", "Shorthand for -source=file://path")

flagConfigDirectory = pflag.String("config.source", defaultConfigDirectory, "directory of the configuration file")
flagConfigFile = pflag.String("config.file", "", "configuration file name without extension")
)
14 changes: 14 additions & 0 deletions cmd/migrate/config/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
help: false
version: false
verbose: true
prefetch: 10
lockTimeout: 15
path: "/atlas-migrations/migrations"
#source: "file:///atlas-migrations/migrations"
database:
driver: postgres
address: postgres:5432
name: app_db
user: postgres
password: postgres
ssl: disable
35 changes: 34 additions & 1 deletion cmd/migrate/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
package main

import "github.com/golang-migrate/migrate/v4/internal/cli"
import (
"log"
"strings"

"github.com/golang-migrate/migrate/v4/internal/cli"
"github.com/infobloxopen/hotload"
_ "github.com/infobloxopen/hotload/fsnotify"
"github.com/jackc/pgx/v4/stdlib"
"github.com/lib/pq"
"github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)

func init() {
pflag.Parse()
viper.BindPFlags(pflag.CommandLine)
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AddConfigPath(viper.GetString("config.source"))
if viper.GetString("config.file") != "" {
viper.SetConfigName(viper.GetString("config.file"))
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("cannot load configuration: %v", err)
}
}
// logrus formatter
customFormatter := new(logrus.JSONFormatter)
logrus.SetFormatter(customFormatter)

hotload.RegisterSQLDriver("pgx", stdlib.GetDefaultDriver())
hotload.RegisterSQLDriver("postgres", pq.Driver{})
hotload.RegisterSQLDriver("postgresql", pq.Driver{})
}

func main() {
cli.Main(Version)
Expand Down
2 changes: 1 addition & 1 deletion docker-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && \
docker build --build-arg VERSION="$TRAVIS_TAG" . -t migrate/migrate -t migrate/migrate:"$TRAVIS_TAG" && \
docker build --pull --build-arg VERSION="$TRAVIS_TAG" . -t migrate/migrate -t migrate/migrate:"$TRAVIS_TAG" && \
docker push migrate/migrate:"$TRAVIS_TAG" && docker push migrate/migrate
Loading