From 3a3be0b766f465c5a641ff896fa40b3dcd13d7c2 Mon Sep 17 00:00:00 2001 From: Vidya Sagar Reddy Desu <35026133+vidya381@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:43:10 -0500 Subject: [PATCH 1/5] add config file support --- cmd/devcheck/main.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmd/devcheck/main.go b/cmd/devcheck/main.go index 8071461..a0db0a0 100644 --- a/cmd/devcheck/main.go +++ b/cmd/devcheck/main.go @@ -2,11 +2,13 @@ package main import ( "context" + "fmt" "os" "sync" "github.com/spf13/cobra" "github.com/vidya381/devcheck/internal/check" + "github.com/vidya381/devcheck/internal/config" "github.com/vidya381/devcheck/internal/detector" "github.com/vidya381/devcheck/internal/reporter" ) @@ -41,9 +43,31 @@ func main() { func run(cmd *cobra.Command, args []string) error { dir, _ := os.Getwd() + cfg, err := config.Load(dir) + if err != nil { + fmt.Fprintf(os.Stderr, "warning: %v\n", err) + } + stack := detector.Detect(dir) checks := check.Build(stack) + // Append extra binary checks from devcheck.yml require: + for _, binary := range cfg.Require { + checks = append(checks, &check.BinaryCheck{Binary: binary}) + } + + // Filter out checks the user asked to skip: + if len(cfg.Skip) > 0 { + skipSet := cfg.SkipSet() + filtered := checks[:0] + for _, c := range checks { + if _, skip := skipSet[c.Name()]; !skip { + filtered = append(filtered, c) + } + } + checks = filtered + } + results := make([]check.Result, len(checks)) var wg sync.WaitGroup From 4a197c7f4e0776a3c929af101966ecd16e14eada Mon Sep 17 00:00:00 2001 From: Vidya Sagar Reddy Desu <35026133+vidya381@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:44:38 -0500 Subject: [PATCH 2/5] add yaml direct dependency --- go.mod | 1 + 1 file changed, 1 insertion(+) diff --git a/go.mod b/go.mod index 669ab24..ae9ac4f 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/redis/go-redis/v9 v9.18.0 github.com/spf13/cobra v1.10.2 go.mongodb.org/mongo-driver/v2 v2.5.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( From 3f5ab2ba79b16a878287beb4c3d7f6c89c4e0240 Mon Sep 17 00:00:00 2001 From: Vidya Sagar Reddy Desu <35026133+vidya381@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:46:31 -0500 Subject: [PATCH 3/5] add config struct and Load(dir) that reads --- internal/config/config.go | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 internal/config/config.go diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 0000000..252679d --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,49 @@ +package config + +import ( + "errors" + "fmt" + "os" + "path/filepath" + + "gopkg.in/yaml.v3" +) + +const Filename = "devcheck.yml" + +// Config holds the parsed contents of a devcheck.yml file. +type Config struct { + // Require lists extra binaries that must be present on PATH. + Require []string `yaml:"require"` + // Skip lists check names (as reported by Check.Name()) to suppress. + Skip []string `yaml:"skip"` +} + +// Load reads devcheck.yml from dir. +// If no config file is present, it returns a zero-value Config and no error. +// Malformed YAML returns an error. +func Load(dir string) (Config, error) { + path := filepath.Join(dir, Filename) + data, err := os.ReadFile(path) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return Config{}, nil + } + return Config{}, fmt.Errorf("reading %s: %w", Filename, err) + } + + var cfg Config + if err := yaml.Unmarshal(data, &cfg); err != nil { + return Config{}, fmt.Errorf("parsing %s: %w", Filename, err) + } + return cfg, nil +} + +// SkipSet returns the Skip list as a set for O(1) lookup. +func (c Config) SkipSet() map[string]struct{} { + s := make(map[string]struct{}, len(c.Skip)) + for _, name := range c.Skip { + s[name] = struct{}{} + } + return s +} \ No newline at end of file From 60019f85c5f84f23d8c5ca614a40427b470a0fcc Mon Sep 17 00:00:00 2001 From: Vidya Sagar Reddy Desu <35026133+vidya381@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:47:37 -0500 Subject: [PATCH 4/5] add tests for load, skip, require, missing file --- internal/config/config_test.go | 110 +++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 internal/config/config_test.go diff --git a/internal/config/config_test.go b/internal/config/config_test.go new file mode 100644 index 0000000..17a3818 --- /dev/null +++ b/internal/config/config_test.go @@ -0,0 +1,110 @@ +package config + +import ( + "os" + "path/filepath" + "testing" +) + +func TestLoad_NoFile_ReturnsEmptyConfig(t *testing.T) { + dir := t.TempDir() + cfg, err := Load(dir) + if err != nil { + t.Fatalf("expected no error when config file absent, got: %v", err) + } + if len(cfg.Require) != 0 || len(cfg.Skip) != 0 { + t.Errorf("expected zero-value config, got: %+v", cfg) + } +} + +func TestLoad_ValidConfig(t *testing.T) { + dir := t.TempDir() + content := ` +require: + - terraform + - aws +skip: + - golangci-lint +` + writeFile(t, filepath.Join(dir, Filename), content) + + cfg, err := Load(dir) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(cfg.Require) != 2 || cfg.Require[0] != "terraform" || cfg.Require[1] != "aws" { + t.Errorf("unexpected Require: %v", cfg.Require) + } + if len(cfg.Skip) != 1 || cfg.Skip[0] != "golangci-lint" { + t.Errorf("unexpected Skip: %v", cfg.Skip) + } +} + +func TestLoad_RequireOnly(t *testing.T) { + dir := t.TempDir() + writeFile(t, filepath.Join(dir, Filename), "require:\n - kubectl\n") + cfg, err := Load(dir) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(cfg.Require) != 1 || cfg.Require[0] != "kubectl" { + t.Errorf("unexpected Require: %v", cfg.Require) + } + if len(cfg.Skip) != 0 { + t.Errorf("expected empty Skip, got: %v", cfg.Skip) + } +} + +func TestLoad_SkipOnly(t *testing.T) { + dir := t.TempDir() + writeFile(t, filepath.Join(dir, Filename), "skip:\n - Node version\n") + cfg, err := Load(dir) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(cfg.Skip) != 1 || cfg.Skip[0] != "Node version" { + t.Errorf("unexpected Skip: %v", cfg.Skip) + } +} + +func TestLoad_InvalidYAML_ReturnsError(t *testing.T) { + dir := t.TempDir() + writeFile(t, filepath.Join(dir, Filename), "require: [unclosed") + _, err := Load(dir) + if err == nil { + t.Fatal("expected error for invalid YAML, got nil") + } +} + +func TestLoad_EmptyFile_ReturnsEmptyConfig(t *testing.T) { + dir := t.TempDir() + writeFile(t, filepath.Join(dir, Filename), "") + cfg, err := Load(dir) + if err != nil { + t.Fatalf("unexpected error for empty file: %v", err) + } + if len(cfg.Require) != 0 || len(cfg.Skip) != 0 { + t.Errorf("expected zero-value config for empty file, got: %+v", cfg) + } +} + +func TestSkipSet(t *testing.T) { + cfg := Config{Skip: []string{"golangci-lint", "Node version"}} + s := cfg.SkipSet() + if _, ok := s["golangci-lint"]; !ok { + t.Error("expected 'golangci-lint' in skip set") + } + if _, ok := s["Node version"]; !ok { + t.Error("expected 'Node version' in skip set") + } + if _, ok := s["docker installed"]; ok { + t.Error("did not expect 'docker installed' in skip set") + } +} + +func writeFile(t *testing.T, path, content string) { + t.Helper() + if err := os.WriteFile(path, []byte(content), 0o644); err != nil { + t.Fatalf("writeFile %s: %v", path, err) + } +} \ No newline at end of file From 90f1e9b8d44a33e86278a4b03199d8bc52282f83 Mon Sep 17 00:00:00 2001 From: Vidya Sagar Reddy Desu <35026133+vidya381@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:52:32 -0500 Subject: [PATCH 5/5] update crypto dependency from v0.33.0 to v0.48.0 --- go.mod | 10 ++++++---- go.sum | 25 +++++++++++++++++-------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index ae9ac4f..48b199f 100644 --- a/go.mod +++ b/go.mod @@ -25,11 +25,13 @@ require ( github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/klauspost/compress v1.17.6 // indirect + github.com/kr/text v0.2.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/muesli/termenv v0.16.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect + github.com/rogpeppe/go-internal v1.14.1 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.2.0 // indirect @@ -37,8 +39,8 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/crypto v0.33.0 // indirect - golang.org/x/sync v0.17.0 // indirect - golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.29.0 // indirect + golang.org/x/crypto v0.48.0 // indirect + golang.org/x/sync v0.19.0 // indirect + golang.org/x/sys v0.41.0 // indirect + golang.org/x/text v0.34.0 // indirect ) diff --git a/go.sum b/go.sum index 5f4cb06..aff5c4a 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,7 @@ github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -42,6 +43,10 @@ github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2e github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -57,6 +62,8 @@ github.com/redis/go-redis/v9 v9.18.0/go.mod h1:k3ufPphLU5YXwNTUcCRXGxUoF1fqxnhFQ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= @@ -88,8 +95,8 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts= +golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos= golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -98,29 +105,31 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= +golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= +golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=