• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mvisonneau / s5 / 20996424938

14 Jan 2026 01:48PM UTC coverage: 32.035% (-14.5%) from 46.573%
20996424938

push

github

mvisonneau
ci: fix tests on GitHub runners

0 of 6 new or added lines in 1 file covered. (0.0%)

161 existing lines in 10 files now uncovered.

222 of 693 relevant lines covered (32.03%)

1.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.0
/pkg/cipher/engine.go
1
package cipher
2

3
import (
4
        "context"
5
        "fmt"
6
        "regexp"
7

8
        "github.com/pkg/errors"
9

10
        "github.com/mvisonneau/s5/pkg/cipher/aes"
11
        "github.com/mvisonneau/s5/pkg/cipher/aws"
12
        "github.com/mvisonneau/s5/pkg/cipher/gcp"
13
        "github.com/mvisonneau/s5/pkg/cipher/pgp"
14
        "github.com/mvisonneau/s5/pkg/cipher/vault"
15
)
16

17
const (
18
        // InputRegexp is defining the syntax of an s5 input variable.
19
        InputRegexp string = `{{\s?s5:([A-Za-z0-9+\\/=]*)\s?}}`
20
)
21

22
// Engine is an interface of supported/required commands for each cipher engine.
23
type Engine interface {
24
        Cipher(ctx context.Context, value string) (string, error)
25
        Decipher(ctx context.Context, value string) (string, error)
26
}
27

28
// NewAESClient creates an AES client.
29
func NewAESClient(key string) (*aes.Client, error) {
2✔
30
        c, err := aes.NewClient(&aes.Config{
2✔
31
                Key: key,
2✔
32
        })
2✔
33
        if err != nil {
3✔
34
                return c, errors.Wrap(err, "creating new AES engine client")
1✔
35
        }
1✔
36

37
        return c, nil
1✔
38
}
39

40
// NewAWSClient creates an AWS client.
41
func NewAWSClient(ctx context.Context, kmsKeyArn string) (*aws.Client, error) {
1✔
42
        c, err := aws.NewClient(ctx, &aws.Config{
1✔
43
                KmsKeyArn: kmsKeyArn,
1✔
44
        })
1✔
45
        if err != nil {
1✔
46
                return c, errors.Wrap(err, "creating new AWS engine client")
×
UNCOV
47
        }
×
48

49
        return c, nil
1✔
50
}
51

52
// NewGCPClient creates a GCP client.
53
func NewGCPClient(ctx context.Context, kmsKeyName string) (*gcp.Client, error) {
×
54
        c, err := gcp.NewClient(ctx, &gcp.Config{
×
55
                KmsKeyName: kmsKeyName,
×
56
        })
×
57
        if err != nil {
×
58
                return c, errors.Wrap(err, "creating new GCP engine client")
×
UNCOV
59
        }
×
60

UNCOV
61
        return c, nil
×
62
}
63

64
// NewPGPClient creates a PGP client.
65
func NewPGPClient(publicKeyPath, privateKeyPath string) (*pgp.Client, error) {
1✔
66
        c, err := pgp.NewClient(&pgp.Config{
1✔
67
                PublicKeyPath:  publicKeyPath,
1✔
68
                PrivateKeyPath: privateKeyPath,
1✔
69
        })
1✔
70
        if err != nil {
2✔
71
                return c, errors.Wrap(err, "creating new PGP engine client")
1✔
72
        }
1✔
73

UNCOV
74
        return c, nil
×
75
}
76

77
// NewVaultClient creates a Vault client.
78
func NewVaultClient(key string) (*vault.Client, error) {
×
79
        c, err := vault.NewClient(&vault.Config{
×
80
                Key: key,
×
81
        })
×
82
        if err != nil {
×
83
                return c, errors.Wrap(err, "creating new Vault engine client")
×
UNCOV
84
        }
×
85

UNCOV
86
        return c, nil
×
87
}
88

89
// GenerateOutput return a ciphered string in a s5 format.
90
func GenerateOutput(value string) string {
2✔
91
        return fmt.Sprintf("{{s5:%s}}", value)
2✔
92
}
2✔
93

94
// ParseInput retrieves ciphered value from a string in the s5 format.
95
func ParseInput(value string) (string, error) {
3✔
96
        re := regexp.MustCompile(InputRegexp)
3✔
97
        if !re.MatchString(value) {
4✔
98
                return "", errors.New("invalid string format, should be '{{s5:*}}'")
1✔
99
        }
1✔
100

101
        return re.FindStringSubmatch(value)[1], nil
2✔
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc