This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit d33b6e20 authored by Georges Racinet on mutations.racinet.fr's avatar Georges Racinet on mutations.racinet.fr
Browse files

Heptapod 0.25 is the new oldstable

See heptapod#573
Pipeline #28840 passed with stage
in 3 minutes and 44 seconds
......@@ -5,7 +5,7 @@
- template: Security/Secret-Detection.gitlab-ci.yml
variables:
DOCKER_VERSION: "19.03.0"
DOCKER_VERSION: "20.10.3"
workflow:
rules: &workflow_rules
......@@ -17,7 +17,7 @@
- if: '$CI_COMMIT_TAG'
default:
image: golang:1.13
image: golang:1.14
tags:
- gitlab-org
......@@ -25,12 +25,8 @@
image: docker:${DOCKER_VERSION}
services:
- docker:${DOCKER_VERSION}-dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
tags:
# See https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/7019 for tag descriptions
- gitlab-org-docker
.test:
......@@ -32,8 +28,10 @@
tags:
# See https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/7019 for tag descriptions
- gitlab-org-docker
.test:
variables:
GITALY_CONNECTION_INFO: '{"address":"tcp://gitaly:8075", "storage":"default"}'
before_script:
# Set up the environment to run integration tests (still written in Ruby)
- apt-get update -qq && apt-get install -y ruby ruby-dev
......@@ -46,6 +44,11 @@
- cp config.yml.example config.yml
- go version
- which go
services:
- name: registry.gitlab.com/gitlab-org/build/cng/gitaly:latest
# Disable the hooks so we don't have to stub the GitLab API
command: ["bash", "-c", "mkdir -p /home/git/repositories && rm -rf /srv/gitlab-shell/hooks/* && exec /usr/bin/env GITALY_TESTING_NO_GIT_HOOKS=1 /scripts/process-wrapper"]
alias: gitaly
script:
- make verify test
......@@ -49,10 +52,6 @@
script:
- make verify test
go:1.13:
extends: .test
image: golang:1.13
go:1.14:
extends: .test
image: golang:1.14
......@@ -67,5 +66,12 @@
- make coverage
coverage: '/\d+.\d+%/'
go:1.16:
extends: .test
image: golang:1.16
after_script:
- make coverage
coverage: '/\d+.\d+%/'
race:
extends: .test
......@@ -70,6 +76,6 @@
race:
extends: .test
image: golang:1.15
image: golang:1.16
script:
- make test_golang_race
......@@ -78,7 +84,7 @@
rules: *workflow_rules
code_navigation:
image: sourcegraph/lsif-go:v1
image: sourcegraph/lsif-go:v1.3.1
allow_failure: true
script:
- lsif-go
......
......@@ -30,3 +30,7 @@
f202fe1e8d044b1ced7dd31be9dc65d4d36a11b1 heptapod-13.14.1
3b2b3737c7a656cf2383fff51d57f51573e9b981 heptapod-13.16.0
4def2dd0132fde7ae4fd57ea21d402860dcd3612 heptapod-13.17.0
ed9dd657a0ab833fd60fe809385f2b73947d0819 heptapod-13.18.0
3cfed32ac2038975b533352ff0f4839aa2a0a319 heptapod-13.18.1
aefbb5e3eac5411fc526a88d3df1762ecbdc2e76 heptapod-13.19.0
b84ce63181d5c0d07585be867dbe957eb6d35348 heptapod-13.19.1
v13.19.1
- Modify regex to prevent partial matches
v13.19.0
- Don't finish the opentracing span early !466
- gitlab-sshd: Respect the ssl_cert_dir config !467
- Stop changing directory to the filesystem root !470
- Fix opentracing setup for gitlab-sshd !473
v13.18.1
- Modify regex to prevent partial matches
v13.18.0
- Fix thread-safety issues in gitlab-shell !463
- gitlab-sshd: Support the PROXY protocol !461
- sshd: Recover from per-session and per-connection panics !464
v13.17.0
- Fix gitlab-shell panic when log file not writable !453
......
......@@ -9,5 +9,23 @@
The corresponding tag is heptapod-x.y.z
## 13.19.1
- No actual changes
## 13.19.0
- Upstream version bump to v13.19.0 (GitLab 14.0 and 14.1 series)
(done as a merge on top of 13.18.1, hence includes the
fixes in upstream 13.19.1.)
## 13.18.1
- Upstream version bump to v13.18.1 (GitLab 13.12.9)
## 13.18.0
- Upstream version bump to v13.18.0 (GitLab 13.12 series)
## 13.17.0
......@@ -12,6 +30,6 @@
## 13.17.0
- Upsteam version bump to v13.17.0 (Gitlab 13.9 *and* 13.10 series)
- Upstream version bump to v13.17.0 (GitLab 13.9 to 13.11 series)
## 13.16.0
......
......@@ -3,7 +3,8 @@
GO_SOURCES := $(shell find . -name '*.go')
VERSION_STRING := $(shell ./compute_version || echo unknown)
BUILD_TIME := $(shell date -u +%Y%m%d.%H%M%S)
GOBUILD_FLAGS := -ldflags "-X main.Version=$(VERSION_STRING) -X main.BuildTime=$(BUILD_TIME)"
BUILD_TAGS := tracer_static tracer_static_jaeger continuous_profiler_stackdriver
GOBUILD_FLAGS := -ldflags "-X main.Version=$(VERSION_STRING) -X main.BuildTime=$(BUILD_TIME)" -tags "$(BUILD_TAGS)"
validate: verify test
......@@ -43,4 +44,4 @@
bin/check
clean:
rm -f bin/check bin/gitlab-shell bin/gitlab-shell-authorized-keys-check bin/gitlab-shell-authorized-principals-check
rm -f bin/check bin/gitlab-shell bin/gitlab-shell-authorized-keys-check bin/gitlab-shell-authorized-principals-check bin/gitlab-sshd
......@@ -35,6 +35,9 @@
Download and install the current version of Go from https://golang.org/dl/
We follow the [Golang Release Policy](https://golang.org/doc/devel/release.html#policy)
of supporting the current stable version and the previous two major versions.
## Setup
make setup
......@@ -61,6 +64,20 @@
bundle install
make validate
### Gitaly
Some tests need a Gitaly server. The
[`docker-compose.yml`](./docker-compose.yml) file will run Gitaly on
port 8075. To tell the tests where Gitaly is, set
`GITALY_CONNECTION_INFO`:
export GITALY_CONNECTION_INFO='{"address": "tcp://localhost:8075", "storage": "default"}'
make test
If no `GITALY_CONNECTION_INFO` is set, the test suite will still run, but any
tests requiring Gitaly will be skipped. They will always run in the CI
environment.
## Git LFS remark
Starting with GitLab 8.12, GitLab supports Git LFS authentication through SSH.
......
......@@ -26,7 +26,7 @@
desc string
relativeURLRoot string
caFile string
server func(*testing.T, []testserver.TestRequestHandler) (string, func())
server func(*testing.T, []testserver.TestRequestHandler) string
}{
{
desc: "Socket client",
......@@ -49,7 +49,7 @@
{
desc: "Https client",
caFile: path.Join(testhelper.TestRoot, "certs/valid/server.crt"),
server: func(t *testing.T, handlers []testserver.TestRequestHandler) (string, func()) {
server: func(t *testing.T, handlers []testserver.TestRequestHandler) string {
return testserver.StartHttpsServer(t, handlers, "")
},
},
......@@ -57,8 +57,7 @@
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
url, cleanup := tc.server(t, buildRequests(t, tc.relativeURLRoot))
defer cleanup()
url := tc.server(t, buildRequests(t, tc.relativeURLRoot))
secret := "sssh, it's a secret"
......
......@@ -48,8 +48,7 @@
},
}
client, cleanup := setup(t, username, password, requests)
defer cleanup()
client := setup(t, username, password, requests)
response, err := client.Get(context.Background(), "/get_endpoint")
require.NoError(t, err)
......@@ -86,8 +85,7 @@
},
}
client, cleanup := setup(t, "", "", requests)
defer cleanup()
client := setup(t, "", "", requests)
_, err := client.Get(context.Background(), "/empty_basic_auth")
require.NoError(t, err)
......@@ -110,8 +108,7 @@
},
}
client, cleanup := setup(t, "", "", requests)
defer cleanup()
client := setup(t, "", "", requests)
_, err := client.Get(context.Background(), "/default_user_agent")
require.NoError(t, err)
......@@ -122,11 +119,11 @@
}
func setup(t *testing.T, username, password string, requests []testserver.TestRequestHandler) (*GitlabNetClient, func()) {
url, cleanup := testserver.StartHttpServer(t, requests)
func setup(t *testing.T, username, password string, requests []testserver.TestRequestHandler) *GitlabNetClient {
url := testserver.StartHttpServer(t, requests)
httpClient := NewHTTPClient(url, "", "", "", false, 1)
client, err := NewGitlabNetClient(username, password, "", httpClient)
require.NoError(t, err)
......@@ -127,8 +124,8 @@
httpClient := NewHTTPClient(url, "", "", "", false, 1)
client, err := NewGitlabNetClient(username, password, "", httpClient)
require.NoError(t, err)
return client, cleanup
return client
}
......@@ -51,8 +51,7 @@
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
client, cleanup := setupWithRequests(t, tc.caFile, tc.caPath, tc.clientCAPath, tc.clientCertPath, tc.clientKeyPath, tc.selfSigned)
defer cleanup()
client := setupWithRequests(t, tc.caFile, tc.caPath, tc.clientCAPath, tc.clientCertPath, tc.clientKeyPath, tc.selfSigned)
response, err := client.Get(context.Background(), "/hello")
require.NoError(t, err)
......@@ -88,8 +87,7 @@
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
client, cleanup := setupWithRequests(t, tc.caFile, tc.caPath, "", "", "", false)
defer cleanup()
client := setupWithRequests(t, tc.caFile, tc.caPath, "", "", "", false)
_, err := client.Get(context.Background(), "/hello")
require.Error(t, err)
......@@ -99,7 +97,7 @@
}
}
func setupWithRequests(t *testing.T, caFile, caPath, clientCAPath, clientCertPath, clientKeyPath string, selfSigned bool) (*GitlabNetClient, func()) {
func setupWithRequests(t *testing.T, caFile, caPath, clientCAPath, clientCertPath, clientKeyPath string, selfSigned bool) *GitlabNetClient {
testDirCleanup, err := testhelper.PrepareTestRootDir()
require.NoError(t, err)
defer testDirCleanup()
......@@ -115,7 +113,7 @@
},
}
url, cleanup := testserver.StartHttpsServer(t, requests, clientCAPath)
url := testserver.StartHttpsServer(t, requests, clientCAPath)
var opts []HTTPClientOpt
if clientCertPath != "" && clientKeyPath != "" {
......@@ -128,5 +126,5 @@
client, err := NewGitlabNetClient("", "", "", httpClient)
require.NoError(t, err)
return client, cleanup
return client
}
......@@ -9,7 +9,7 @@
"testing"
"github.com/stretchr/testify/require"
pb "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
......@@ -58,6 +58,8 @@
return nil
}
func StartGitalyServer(t *testing.T) (string, *TestGitalyServer, func()) {
func StartGitalyServer(t *testing.T) (string, *TestGitalyServer) {
t.Helper()
tempDir, _ := ioutil.TempDir("", "gitlab-shell-test-api")
gitalySocketPath := path.Join(tempDir, "gitaly.sock")
......@@ -62,5 +64,6 @@
tempDir, _ := ioutil.TempDir("", "gitlab-shell-test-api")
gitalySocketPath := path.Join(tempDir, "gitaly.sock")
t.Cleanup(func() { os.RemoveAll(tempDir) })
err := os.MkdirAll(filepath.Dir(gitalySocketPath), 0700)
require.NoError(t, err)
......@@ -74,5 +77,6 @@
pb.RegisterSSHServiceServer(server, &testServer)
go server.Serve(listener)
t.Cleanup(func() { server.Stop() })
gitalySocketUrl := "unix:" + gitalySocketPath
......@@ -77,7 +81,3 @@
gitalySocketUrl := "unix:" + gitalySocketPath
cleanup := func() {
server.Stop()
os.RemoveAll(tempDir)
}
......@@ -83,3 +83,3 @@
return gitalySocketUrl, &testServer, cleanup
return gitalySocketUrl, &testServer
}
......@@ -27,6 +27,8 @@
Handler func(w http.ResponseWriter, r *http.Request)
}
func StartSocketHttpServer(t *testing.T, handlers []TestRequestHandler) (string, func()) {
func StartSocketHttpServer(t *testing.T, handlers []TestRequestHandler) string {
t.Helper()
err := os.MkdirAll(filepath.Dir(testSocket), 0700)
require.NoError(t, err)
......@@ -31,5 +33,6 @@
err := os.MkdirAll(filepath.Dir(testSocket), 0700)
require.NoError(t, err)
t.Cleanup(func() { os.RemoveAll(tempDir) })
socketListener, err := net.Listen("unix", testSocket)
require.NoError(t, err)
......@@ -44,6 +47,6 @@
url := "http+unix://" + testSocket
return url, cleanupSocket
return url
}
......@@ -48,4 +51,6 @@
}
func StartHttpServer(t *testing.T, handlers []TestRequestHandler) (string, func()) {
func StartHttpServer(t *testing.T, handlers []TestRequestHandler) string {
t.Helper()
server := httptest.NewServer(buildHandler(handlers))
......@@ -51,2 +56,3 @@
server := httptest.NewServer(buildHandler(handlers))
t.Cleanup(func() { server.Close() })
......@@ -52,4 +58,4 @@
return server.URL, server.Close
return server.URL
}
......@@ -54,6 +60,8 @@
}
func StartHttpsServer(t *testing.T, handlers []TestRequestHandler, clientCAPath string) (string, func()) {
func StartHttpsServer(t *testing.T, handlers []TestRequestHandler, clientCAPath string) string {
t.Helper()
crt := path.Join(testhelper.TestRoot, "certs/valid/server.crt")
key := path.Join(testhelper.TestRoot, "certs/valid/server.key")
......@@ -63,7 +71,7 @@
server.TLS = &tls.Config{
Certificates: []tls.Certificate{cer},
MinVersion: tls.VersionTLS12,
MinVersion: tls.VersionTLS12,
}
server.TLS.BuildNameToCertificate()
......@@ -80,6 +88,5 @@
server.StartTLS()
return server.URL, server.Close
}
t.Cleanup(func() { server.Close() })
......@@ -85,6 +92,5 @@
func cleanupSocket() {
os.RemoveAll(tempDir)
return server.URL
}
func buildHandler(handlers []TestRequestHandler) http.Handler {
......
......@@ -9,6 +9,7 @@
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
"gitlab.com/gitlab-org/gitlab-shell/internal/logger"
"gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
)
func main() {
......@@ -32,9 +33,9 @@
logger.Configure(config)
cmd, err := command.New(executable, os.Args[1:], config, readWriter)
cmd, err := command.New(executable, os.Args[1:], sshenv.Env{}, config, readWriter)
if err != nil {
fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
os.Exit(1)
}
......@@ -36,9 +37,9 @@
if err != nil {
fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
os.Exit(1)
}
ctx, finished := command.ContextWithCorrelationID()
ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
......
......@@ -10,6 +10,7 @@
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
"gitlab.com/gitlab-org/gitlab-shell/internal/logger"
"gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
)
func main() {
......@@ -33,7 +34,7 @@
logger.Configure(config)
cmd, err := command.New(executable, os.Args[1:], config, readWriter)
cmd, err := command.New(executable, os.Args[1:], sshenv.Env{}, config, readWriter)
if err != nil {
// For now this could happen if `SSH_CONNECTION` is not set on
// the environment
......@@ -41,7 +42,7 @@
os.Exit(1)
}
ctx, finished := command.ContextWithCorrelationID()
ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
......
......@@ -10,6 +10,7 @@
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
"gitlab.com/gitlab-org/gitlab-shell/internal/logger"
"gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
)
func main() {
......@@ -33,7 +34,7 @@
logger.Configure(config)
cmd, err := command.New(executable, os.Args[1:], config, readWriter)
cmd, err := command.New(executable, os.Args[1:], sshenv.Env{}, config, readWriter)
if err != nil {
// For now this could happen if `SSH_CONNECTION` is not set on
// the environment
......@@ -41,7 +42,7 @@
os.Exit(1)
}
ctx, finished := command.ContextWithCorrelationID()
ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
......
......@@ -10,6 +10,7 @@
"gitlab.com/gitlab-org/gitlab-shell/internal/console"
"gitlab.com/gitlab-org/gitlab-shell/internal/executable"
"gitlab.com/gitlab-org/gitlab-shell/internal/logger"
"gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
)
var (
......@@ -47,7 +48,8 @@
logger.Configure(config)
cmd, err := command.New(executable, os.Args[1:], config, readWriter)
env := sshenv.NewFromEnv()
cmd, err := command.New(executable, os.Args[1:], env, config, readWriter)
if err != nil {
// For now this could happen if `SSH_CONNECTION` is not set on
// the environment
......@@ -55,7 +57,7 @@
os.Exit(1)
}
ctx, finished := command.ContextWithCorrelationID()
ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
......
package main_test
import (
"bufio"
"context"
"crypto/ed25519"
"encoding/json"
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strings"
"testing"
"github.com/mikesmitty/edkey"
"github.com/pires/go-proxyproto"
"github.com/stretchr/testify/require"
gitalyClient "gitlab.com/gitlab-org/gitaly/v14/client"
pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitlab-shell/internal/testhelper"
"golang.org/x/crypto/ssh"
)
var (
sshdPath = ""
gitalyConnInfo *gitalyConnectionInfo
)
const (
testRepo = "test-gitlab-shell/gitlab-test.git"
testRepoNamespace = "test-gitlab-shell"
testRepoImportUrl = "https://gitlab.com/gitlab-org/gitlab-test.git"
)
type gitalyConnectionInfo struct {
Address string `json:"address"`
Storage string `json:"storage"`
}
func init() {
rootDir := rootDir()
sshdPath = filepath.Join(rootDir, "bin", "gitlab-sshd")
if _, err := os.Stat(sshdPath); os.IsNotExist(err) {
panic(fmt.Errorf("cannot find executable %s. Please run 'make compile'", sshdPath))
}
gci, exists := os.LookupEnv("GITALY_CONNECTION_INFO")
if exists {
json.Unmarshal([]byte(gci), &gitalyConnInfo)
}
}
func rootDir() string {
_, currentFile, _, ok := runtime.Caller(0)
if !ok {
panic(fmt.Errorf("rootDir: calling runtime.Caller failed"))
}