Redis: Store the major, minor, and patchlevel as ints as well as the whole version as a string

This commit is contained in:
Ricky Diaz Gomez 2019-06-28 15:54:11 -04:00
parent 7c651c0be5
commit 67fbf1facb
2 changed files with 22 additions and 0 deletions

View File

@ -89,6 +89,15 @@ type Result struct {
// present.
Version string `json:"version,omitempty"`
// Major is the version's major number.
Major uint32 `json:"major,omitempty"`
// Minor is the version's minor number.
Minor uint32 `json:"minor,omitempty"`
// Patchlevel is the version's patchlevel number.
Patchlevel uint32 `json:"patchlevel,omitempty"`
// OS is read from the InfoResponse (the field "os"), if present. It specifies
// the OS the redis server is running.
OS string `json:"os,omitempty"`
@ -403,6 +412,16 @@ func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, inter
switch prefix {
case "redis_version":
result.Version = suffix
versionSegments := strings.SplitN(suffix, ".", 3)
if len(versionSegments) > 0 {
result.Major = convToUint32(versionSegments[0])
}
if len(versionSegments) > 1 {
result.Minor = convToUint32(versionSegments[1])
}
if len(versionSegments) > 2 {
result.Patchlevel = convToUint32(versionSegments[2])
}
case "os":
result.OS = suffix
case "arch_bits":

View File

@ -25,6 +25,9 @@ redis_scan_response = SubRecord({
]),
"quit_response": String(doc="The response to the QUIT command.", examples=["OK"]),
"version": String(doc="The version string, read from the the info_response (if available)."),
"major": Unsigned32BitInteger(doc="Major is the version's major number."),
"minor": Unsigned32BitInteger(doc="Minor is the version's minor number."),
"patchlevel": Unsigned32BitInteger(doc="Patchlevel is the version's patchlevel number."),
"os": String(doc="The OS the Redis server is running, read from the the info_response (if available)."),
"mode": String(doc="The mode the Redis server is running (standalone or cluster), read from the the info_response (if available)."),
"git_sha1": String(doc="The Sha-1 Git commit hash the Redis server used."),