MCPcopy Create free account
hub / github.com/Malayke/Next.js-RSC-RCE-Scanner-CVE-2025-66478 / parseVersion

Function parseVersion

scanner.go:276–302  ·  view source on GitHub ↗

parseVersion parses version string Returns: major, minor, patch, isCanary, canaryNumber

(version string)

Source from the content-addressed store, hash-verified

274// parseVersion parses version string
275// Returns: major, minor, patch, isCanary, canaryNumber
276func parseVersion(version string) (int, int, int, bool, int) {
277 // Remove "v" prefix
278 version = strings.TrimPrefix(version, "v")
279
280 // Check if it's a canary version
281 isCanary := strings.Contains(version, "canary")
282 canaryNum := 0
283
284 // Regular expression to match version number
285 // Format: 14.3.0-canary.77 or 15.0.1
286 re := regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)(?:-canary\.(\d+))?`)
287 matches := re.FindStringSubmatch(version)
288
289 if len(matches) < 4 {
290 return 0, 0, 0, false, 0
291 }
292
293 major, _ := strconv.Atoi(matches[1])
294 minor, _ := strconv.Atoi(matches[2])
295 patch, _ := strconv.Atoi(matches[3])
296
297 if len(matches) > 4 && matches[4] != "" {
298 canaryNum, _ = strconv.Atoi(matches[4])
299 }
300
301 return major, minor, patch, isCanary, canaryNum
302}

Callers 2

isVulnerableFunction · 0.85
TestParseVersionFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseVersionFunction · 0.68