| 89 | |
| 90 | func (c EnvCheck) Name() string { return "Environment File Check" } |
| 91 | func (c EnvCheck) Run(_ context.Context, r Reporter) Result { |
| 92 | res := Result{} |
| 93 | path, err := envfile.Find(c.Custom, false) |
| 94 | if err != nil { |
| 95 | if errors.Is(err, envfile.ErrNotFound) { |
| 96 | res.Issues++ |
| 97 | r.Warn("No .env file found", "Create one for sensitive credentials") |
| 98 | return res |
| 99 | } |
| 100 | res.Issues++ |
| 101 | r.Fail("Unable to locate .env", err.Error()) |
| 102 | return res |
| 103 | } |
| 104 | r.Pass(fmt.Sprintf("Environment file found: %s", path)) |
| 105 | if info, err := os.Stat(path); err == nil { |
| 106 | perms := info.Mode().Perm() |
| 107 | if perms == 0o600 || perms == 0o400 { |
| 108 | r.Pass("Environment file has secure permissions") |
| 109 | } else { |
| 110 | res.Issues++ |
| 111 | r.Warn(fmt.Sprintf("Environment file permissions: %o", perms), |
| 112 | "Consider chmod 600 for secure storage of API keys") |
| 113 | } |
| 114 | } |
| 115 | return res |
| 116 | } |
| 117 | |
| 118 | // EndpointFormatCheck verifies every endpoint URL starts with http(s)://. |
| 119 | type EndpointFormatCheck struct { |