drakkan / sftpgo

Compare db80781 ... +249 ... 0ecaa86

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 60 of 300 files from the diff.
Newly tracked file
httpd/flash.go created.
Newly tracked file
command/command.go created.
Newly tracked file
httpd/resetcode.go created.
Newly tracked file
mfa/mfa.go created.
Newly tracked file
httpd/webclient.go created.
Newly tracked file
httpd/oidcmanager.go created.
Newly tracked file
httpd/api_retention.go created.
Newly tracked file
httpd/api_shares.go created.
Newly tracked file
httpd/oidc.go created.
Newly tracked file
httpd/file.go created.
Newly tracked file
httpd/api_events.go created.
Newly tracked file
httpd/api_http_user.go created.
Newly tracked file
httpd/webadmin.go created.
Newly tracked file
mfa/totp.go created.
Newly tracked file
httpd/handler.go created.
Newly tracked file
httpd/api_mfa.go created.
Newly tracked file
sftpd/middleware.go created.
Newly tracked file
httpd/api_group.go created.
Newly tracked file
httpd/api_keys.go created.
Newly tracked file
httpd/api_metadata.go created.
Other files ignored by Codecov
LICENSE has changed.
kms/basesecret.go has changed.
DCO is new.
cmd/root.go has changed.
docs/metrics.md has changed.
cmd/serve.go has changed.
sftpgo.json has changed.
cmd/genman.go has changed.
docs/account.md has changed.
docs/service.md has changed.
kms/gcp.go was deleted.
ftpd/ftpd_test.go has changed.
metric/metric.go has changed.
kms/local.go has changed.
kms/kms.go has changed.
Dockerfile has changed.
docs/defender.md has changed.
docs/webdav.md has changed.
docs/web-admin.md has changed.
kms/disabled.go was deleted.
cmd/portable.go has changed.
docs/sftpfs.md has changed.
docs/rest-api.md has changed.
kms/aws.go was deleted.
go.mod has changed.
docs/s3.md has changed.
README.md has changed.
main.go has changed.
.golangci.yml has changed.
Dockerfile.alpine has changed.
pkgs/build.sh has changed.
docs/dare.md has changed.
docs/profiling.md has changed.
docker/README.md has changed.
kms/builtin.go has changed.
go.sum has changed.
docs/kms.md has changed.
logger/logger.go has changed.
kms/vault.go was deleted.
docs/logs.md has changed.

@@ -1,7 +1,6 @@
Loading
1 +
//go:build !linux
1 2
// +build !linux
2 3
3 4
package config
4 5
5 -
func setViperAdditionalConfigPaths() {
6 -
7 -
}
6 +
func setViperAdditionalConfigPaths() {}

@@ -0,0 +1,100 @@
Loading
1 +
package command
2 +
3 +
import (
4 +
	"fmt"
5 +
	"os"
6 +
	"strings"
7 +
	"time"
8 +
)
9 +
10 +
const (
11 +
	minTimeout     = 1
12 +
	maxTimeout     = 300
13 +
	defaultTimeout = 30
14 +
)
15 +
16 +
var (
17 +
	config Config
18 +
)
19 +
20 +
// Command define the configuration for a specific commands
21 +
type Command struct {
22 +
	// Path is the command path as defined in the hook configuration
23 +
	Path string `json:"path" mapstructure:"path"`
24 +
	// Timeout specifies a time limit, in seconds, for the command execution.
25 +
	// This value overrides the global timeout if set.
26 +
	// Do not use variables with the SFTPGO_ prefix to avoid conflicts with env
27 +
	// vars that SFTPGo sets
28 +
	Timeout int `json:"timeout" mapstructure:"timeout"`
29 +
	// Env defines additional environment variable for the commands.
30 +
	// Each entry is of the form "key=value".
31 +
	// These values are added to the global environment variables if any
32 +
	Env []string `json:"env" mapstructure:"env"`
33 +
}
34 +
35 +
// Config defines the configuration for external commands such as
36 +
// program based hooks
37 +
type Config struct {
38 +
	// Timeout specifies a global time limit, in seconds, for the external commands execution
39 +
	Timeout int `json:"timeout" mapstructure:"timeout"`
40 +
	// Env defines additional environment variable for the commands.
41 +
	// Each entry is of the form "key=value".
42 +
	// Do not use variables with the SFTPGO_ prefix to avoid conflicts with env
43 +
	// vars that SFTPGo sets
44 +
	Env []string `json:"env" mapstructure:"env"`
45 +
	// Commands defines configuration for specific commands
46 +
	Commands []Command `json:"commands" mapstructure:"commands"`
47 +
}
48 +
49 +
func init() {
50 +
	config = Config{
51 +
		Timeout: defaultTimeout,
52 +
	}
53 +
}
54 +
55 +
// Initialize configures commands
56 +
func (c Config) Initialize() error {
57 +
	if c.Timeout < minTimeout || c.Timeout > maxTimeout {
58 +
		return fmt.Errorf("invalid timeout %v", c.Timeout)
59 +
	}
60 +
	for _, env := range c.Env {
61 +
		if len(strings.Split(env, "=")) != 2 {
62 +
			return fmt.Errorf("invalid env var %#v", env)
63 +
		}
64 +
	}
65 +
	for idx, cmd := range c.Commands {
66 +
		if cmd.Path == "" {
67 +
			return fmt.Errorf("invalid path %#v", cmd.Path)
68 +
		}
69 +
		if cmd.Timeout == 0 {
70 +
			c.Commands[idx].Timeout = c.Timeout
71 +
		} else {
72 +
			if cmd.Timeout < minTimeout || cmd.Timeout > maxTimeout {
73 +
				return fmt.Errorf("invalid timeout %v for command %#v", cmd.Timeout, cmd.Path)
74 +
			}
75 +
		}
76 +
		for _, env := range cmd.Env {
77 +
			if len(strings.Split(env, "=")) != 2 {
78 +
				return fmt.Errorf("invalid env var %#v for command %#v", env, cmd.Path)
79 +
			}
80 +
		}
81 +
	}
82 +
	config = c
83 +
	return nil
84 +
}
85 +
86 +
// GetConfig returns the configuration for the specified command
87 +
func GetConfig(command string) (time.Duration, []string) {
88 +
	env := os.Environ()
89 +
	timeout := time.Duration(config.Timeout) * time.Second
90 +
	env = append(env, config.Env...)
91 +
	for _, cmd := range config.Commands {
92 +
		if cmd.Path == command {
93 +
			timeout = time.Duration(cmd.Timeout) * time.Second
94 +
			env = append(env, cmd.Env...)
95 +
			break
96 +
		}
97 +
	}
98 +
99 +
	return timeout, env
100 +
}

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 68 files with coverage changes found.

Changes in sftpd/handler.go
+181
+1
+3
Loading file...
Changes in sftpd/server.go
+336
+1
+5
Loading file...
Changes in telemetry/telemetry.go
+19
Loading file...
Changes in common/connection.go
+33
Loading file...
Changes in config/config_linux.go
+1
Loading file...
Changes in sftpd/sftpd.go
+6
Loading file...
Changes in httpd/api_maintenance.go
+134
Loading file...
Changes in httpd/auth_utils.go
+108
Loading file...
Changes in httpd/httpd.go
+269
Loading file...
Changes in httpd/api_user.go
+89
Loading file...
Changes in httpd/api_folder.go
+48
Loading file...
Changes in ftpd/server.go
+149
Loading file...
Changes in config/config.go
+36
Loading file...
Changes in httpd/server.go
+1121
Loading file...
Changes in webdavd/handler.go
+72
Loading file...
Changes in webdavd/webdavd.go
+38
Loading file...
Changes in sftpd/ssh_cmd.go
+187
Loading file...
Changes in webdavd/server.go
+111
Loading file...
Changes in httpd/api_admin.go
+150
Loading file...
Changes in httpd/web.go
-881
Loading file...
Changes in sftpd/transfer.go
+41
Loading file...
Changes in httpd/middleware.go
+289
Loading file...
Changes in common/tlsutils.go
+33
Loading file...
Changes in ftpd/ftpd.go
+98
Loading file...
Changes in common/httpauth.go
+18
Loading file...
Changes in sftpd/lister.go
+3
Loading file...
Changes in httpd/api_utils.go
+457
Loading file...
Changes in webdavd/file.go
+83
Loading file...
Changes in httpd/api_quota.go
+111
Loading file...
Changes in telemetry/router.go
+10
Loading file...
Changes in httpd/api_defender.go
+80
Loading file...
Changes in ftpd/transfer.go
+26
Loading file...
Changes in webdavd/mimecache.go
+7
Loading file...
Changes in common/transfer.go
+17
Loading file...
Changes in sftpd/cmd_unix.go
+2
Loading file...
Changes in common/actions.go
+2
Loading file...
Changes in common/common.go
+50
Loading file...
Changes in ftpd/handler.go
+152
Loading file...
Changes in common/defender.go
+16
Loading file...
Changes in sftpd/subsystem.go
+18
Loading file...
New file httpd/handler.go
New
Loading file...
New file config/config_nolinux.go
New
Loading file...
New file command/command.go
New
Loading file...
New file httpd/file.go
New
Loading file...
New file httpd/oidcmanager.go
New
Loading file...
New file httpd/api_retention.go
New
Loading file...
New file httpd/api_mfa.go
New
Loading file...
New file common/dataretention.go
New
Loading file...
New file sftpd/middleware.go
New
Loading file...
New file common/ratelimiter.go
New
Loading file...
New file httpd/api_shares.go
New
Loading file...
New file httpd/flash.go
New
Loading file...
New file httpd/api_group.go
New
Loading file...
New file common/clientsmap.go
New
Loading file...
New file mfa/totp.go
New
Loading file...
New file common/defendermem.go
New
Loading file...
New file common/defenderdb.go
New
Loading file...
New file httpd/api_keys.go
New
Loading file...
New file mfa/mfa.go
New
Loading file...
New file common/transferschecker.go
New
Loading file...
New file httpd/api_events.go
New
Loading file...
New file httpd/oidc.go
New
Loading file...
New file httpd/api_http_user.go
New
Loading file...
New file httpd/webadmin.go
New
Loading file...
New file httpd/webclient.go
New
Loading file...
New file httpd/resetcode.go
New
Loading file...
New file httpd/api_metadata.go
New
Loading file...
Changes in sftpd/scp.go
-2
+179
+5
Loading file...

251 Commits

+10
+10
+1 Files
+81
+81
+1 Files
+115
+115
+1
+1
+2
+2
+2
+2
+38
+38
+74
+74
+45
+45
+3
+3
+36
+40
-1
-3
Hiding 1 contexual commits
+46
+46
-2
-2
+9
+9
+1 Files
+404
+401
+1
+2
+59
+59
+18
+18
+13
+13
+3
+3
+7
+7
Hiding 4 contexual commits
+120
+120
+1
+1
+20
+20
+13
+13
+34
+34
+10
+10
+6
+6
+1
+1
+3
+3
+1 Files
+1
+1
-1 Files
-1
-1
+51
+51
+41
+41
+3
+3
+1
+1
+4
+4
+87
+87
-3
-3
+1
+1
+1
+1
+29
+29
+21
+21
-23
-23
+1
+1
+1
+1
-3
-3
+7
+7
+8
+8
+22
+22
+25
+25
+135
+135
+1
+1
+31
+31
+25
+25
+2 Files
+677
+677
+206
+206
+4
+4
+1 Files
+8
+8
-1 Files
+5
+5
+6
+6
+366
+373
-2
-5
+1 Files
+241
+241
Hiding 1 contexual commits
-3
-3
+45
+45
+24
+24
+23
+23
+20
+20
Hiding 1 contexual commits
+2
+2
Hiding 1 contexual commits
-15
-15
+9
+9
Hiding 1 contexual commits
+15
+15
+5
+5
+2 Files
+136
+136
Hiding 1 contexual commits
+50
+50
+1 Files
+70
+70
+37
+37
+121
+121
+1
+1
+32
+32
+5
+5
+25
+25
+57
+57
-1
-1
+1
+1
+23
+23
+26
+26
Hiding 1 contexual commits
+65
+65
+3
+3
+2
+2
+31
+31
+2
+2
Hiding 1 contexual commits
+1
+1
+2
+2
+2
+2
+25
+25
+28
+28
+1
+1
+1 Files
+381
+381
+2 Files
+453
+449
+1
+3
-1 Files
+9
+9
+56
+56
+1 Files
+112
+112
+8
+8
+93
+96
-1
-2
Hiding 1 contexual commits
+56 Files
+14389
+14343
+12
+34
-56 Files
-14301
-14258
-11
-32
+17
+17
+83
+83