Skip to content

Commit f4fdbda

Browse files
authored
Format code and fix file permissions (#13)
Ran gofmt/goimports over the entire codebase and set file permissions to the default 0644.
1 parent c26ac4a commit f4fdbda

14 files changed

Lines changed: 822 additions & 822 deletions

File tree

config.yaml

100755100644
File mode changed.

core/banner.go

100755100644
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package core
2-
3-
const (
4-
Name = "shhgit"
5-
Version = "0.2"
6-
Author = "Paul Price (@darkp0rt)"
7-
)
1+
package core
2+
3+
const (
4+
Name = "shhgit"
5+
Version = "0.2"
6+
Author = "Paul Price (@darkp0rt)"
7+
)

core/config.go

100755100644
Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
package core
2-
3-
import (
4-
"errors"
5-
"io/ioutil"
6-
"os"
7-
"path"
8-
"strings"
9-
10-
"gopkg.in/yaml.v3"
11-
)
12-
13-
type Config struct {
14-
GitHubAccessTokens []string `yaml:"github_access_tokens"`
15-
SlackWebhook string `yaml:"slack_webhook,omitempty"`
16-
BlacklistedExtensions []string `yaml:"blacklisted_extensions"`
17-
BlacklistedPaths []string `yaml:"blacklisted_paths"`
18-
BlacklistedEntropyExtensions []string `yaml:"blacklisted_entropy_extensions"`
19-
Signatures []ConfigSignature `yaml:"signatures"`
20-
}
21-
22-
type ConfigSignature struct {
23-
Name string `yaml:"name"`
24-
Part string `yaml:"part"`
25-
Match string `yaml:"match,omitempty"`
26-
Regex string `yaml:"regex,omitempty"`
27-
Verifier string `yaml:"verifier,omitempty"`
28-
}
29-
30-
func ParseConfig() (*Config, error) {
31-
config := &Config{}
32-
33-
dir, _ := os.Getwd()
34-
data, err := ioutil.ReadFile(path.Join(dir, "config.yaml"))
35-
if err != nil {
36-
return config, err
37-
}
38-
39-
err = yaml.Unmarshal(data, config)
40-
if err != nil {
41-
return config, err
42-
}
43-
44-
for i := 0; i < len(config.GitHubAccessTokens); i++ {
45-
config.GitHubAccessTokens[i] = os.ExpandEnv(config.GitHubAccessTokens[i])
46-
}
47-
48-
if len(config.SlackWebhook) > 0 {
49-
config.SlackWebhook = os.ExpandEnv(config.SlackWebhook)
50-
}
51-
52-
return config, nil
53-
}
54-
55-
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
56-
*c = Config{}
57-
type plain Config
58-
err := unmarshal((*plain)(c))
59-
60-
if err != nil {
61-
return err
62-
}
63-
64-
if len(c.GitHubAccessTokens) < 1 || strings.TrimSpace(strings.Join(c.GitHubAccessTokens, "")) == "" {
65-
return errors.New("You need to provide at least one GitHub Access Token. See https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line")
66-
}
67-
68-
return nil
69-
}
1+
package core
2+
3+
import (
4+
"errors"
5+
"io/ioutil"
6+
"os"
7+
"path"
8+
"strings"
9+
10+
"gopkg.in/yaml.v3"
11+
)
12+
13+
type Config struct {
14+
GitHubAccessTokens []string `yaml:"github_access_tokens"`
15+
SlackWebhook string `yaml:"slack_webhook,omitempty"`
16+
BlacklistedExtensions []string `yaml:"blacklisted_extensions"`
17+
BlacklistedPaths []string `yaml:"blacklisted_paths"`
18+
BlacklistedEntropyExtensions []string `yaml:"blacklisted_entropy_extensions"`
19+
Signatures []ConfigSignature `yaml:"signatures"`
20+
}
21+
22+
type ConfigSignature struct {
23+
Name string `yaml:"name"`
24+
Part string `yaml:"part"`
25+
Match string `yaml:"match,omitempty"`
26+
Regex string `yaml:"regex,omitempty"`
27+
Verifier string `yaml:"verifier,omitempty"`
28+
}
29+
30+
func ParseConfig() (*Config, error) {
31+
config := &Config{}
32+
33+
dir, _ := os.Getwd()
34+
data, err := ioutil.ReadFile(path.Join(dir, "config.yaml"))
35+
if err != nil {
36+
return config, err
37+
}
38+
39+
err = yaml.Unmarshal(data, config)
40+
if err != nil {
41+
return config, err
42+
}
43+
44+
for i := 0; i < len(config.GitHubAccessTokens); i++ {
45+
config.GitHubAccessTokens[i] = os.ExpandEnv(config.GitHubAccessTokens[i])
46+
}
47+
48+
if len(config.SlackWebhook) > 0 {
49+
config.SlackWebhook = os.ExpandEnv(config.SlackWebhook)
50+
}
51+
52+
return config, nil
53+
}
54+
55+
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
56+
*c = Config{}
57+
type plain Config
58+
err := unmarshal((*plain)(c))
59+
60+
if err != nil {
61+
return err
62+
}
63+
64+
if len(c.GitHubAccessTokens) < 1 || strings.TrimSpace(strings.Join(c.GitHubAccessTokens, "")) == "" {
65+
return errors.New("You need to provide at least one GitHub Access Token. See https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line")
66+
}
67+
68+
return nil
69+
}

core/git.go

100755100644
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
package core
2-
3-
import (
4-
"context"
5-
"time"
6-
7-
"gopkg.in/src-d/go-git.v4"
8-
)
9-
10-
func CloneRepository(session *Session, url string, dir string) (*git.Repository, error) {
11-
localCtx, cancel := context.WithTimeout(session.Context, time.Duration(*session.Options.CloneRepositoryTimeout)*time.Second)
12-
defer cancel()
13-
14-
repository, err := git.PlainCloneContext(localCtx, dir, false, &git.CloneOptions{
15-
Depth: 1,
16-
RecurseSubmodules: git.NoRecurseSubmodules,
17-
URL: url,
18-
SingleBranch: true,
19-
Tags: git.NoTags,
20-
})
21-
22-
if err != nil {
23-
return nil, err
24-
}
25-
26-
return repository, nil
27-
}
1+
package core
2+
3+
import (
4+
"context"
5+
"time"
6+
7+
"gopkg.in/src-d/go-git.v4"
8+
)
9+
10+
func CloneRepository(session *Session, url string, dir string) (*git.Repository, error) {
11+
localCtx, cancel := context.WithTimeout(session.Context, time.Duration(*session.Options.CloneRepositoryTimeout)*time.Second)
12+
defer cancel()
13+
14+
repository, err := git.PlainCloneContext(localCtx, dir, false, &git.CloneOptions{
15+
Depth: 1,
16+
RecurseSubmodules: git.NoRecurseSubmodules,
17+
URL: url,
18+
SingleBranch: true,
19+
Tags: git.NoTags,
20+
})
21+
22+
if err != nil {
23+
return nil, err
24+
}
25+
26+
return repository, nil
27+
}

0 commit comments

Comments
 (0)