MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / CheckSemantics

Function CheckSemantics

tools/bash/security.go:247–275  ·  view source on GitHub ↗
(command string)

Source from the content-addressed store, hash-verified

245}
246
247func CheckSemantics(command string) string {
248 extraction := ExtractQuotedContent(command)
249 target := extraction.FullyUnquoted
250 for _, pattern := range commandSubstitutionPatterns[:3] {
251 if pattern.re.MatchString(target) {
252 return "dangerous"
253 }
254 }
255 indicators := []*regexp.Regexp{
256 regexp.MustCompile("`[^`]+`"),
257 regexp.MustCompile(`\$\([^)]+\)`),
258 regexp.MustCompile(`\|.*\|`),
259 regexp.MustCompile(`&&.*&&`),
260 regexp.MustCompile(`\|\|.*\|\|`),
261 }
262 score := 0
263 for _, indicator := range indicators {
264 if indicator.MatchString(target) {
265 score++
266 }
267 }
268 if score >= 3 {
269 return "too-complex"
270 }
271 if score >= 1 {
272 return "dangerous"
273 }
274 return "safe"
275}
276
277func checkCommandSubstitution(command string) []SecurityFinding {
278 target := ExtractQuotedContent(command).WithDoubleQuotes

Callers 1

analyzeSingleCommandFunction · 0.85

Calls 1

ExtractQuotedContentFunction · 0.85

Tested by

no test coverage detected