Skip to content

Commit

Permalink
refactor: to keep the capitalization convention
Browse files Browse the repository at this point in the history
  • Loading branch information
fukusuket committed Mar 3, 2024
1 parent 78ab636 commit fe7efcd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/takajo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ include takajopkg/splitJsonTimeline
include takajopkg/stackCmdlines
include takajopkg/stackComputers
include takajopkg/stackDNS
include takajopkg/stackIpaddresses
include takajopkg/stackIpAddresses
include takajopkg/stackLogons
include takajopkg/stackProcesses
include takajopkg/stackServices
Expand Down Expand Up @@ -230,7 +230,7 @@ when isMainModule:
}
],
[
stackIpaddresses, cmdName = "stack-ip-addresses",
stackIpAddresses, cmdName = "stack-ip-addresses",
doc = "stack ipaddresses",
help = {
"level": "specify the minimum alert level (default: informational)",
Expand Down
29 changes: 7 additions & 22 deletions src/takajopkg/stackComputers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,12 @@ proc stackComputers(level: string = "informational", sourceComputers: bool = fal
let startTime = epochTime()
checkArgs(quiet, timeline, level)
let totalLines = countJsonlAndStartMsg("Computers", "the Computer field as well as show alert information", timeline)
var
bar: SuruBar = initSuruBar()
stack = initTable[string, StackRecord]()
bar[0].total = totalLines
bar.setup()
# Loop through JSON lines
for line in lines(timeline):
inc bar
bar.update(1000000000) # refresh every second
let jsonLineOpt = parseLine(line)
if jsonLineOpt.isNone:
continue
let jsonLine:HayabusaJson = jsonLineOpt.get()
let eventId = jsonLine.EventID
let channel = jsonLine.Channel
var stackKey = jsonLine.Computer
let eventFilter = proc(x: HayabusaJson): bool = true
let getStackKey = proc(x: HayabusaJson): (string, seq[string]) =
var stackKey = x.Computer
if sourceComputers:
stackKey = getJsonValue(jsonLine.Details, @["SrcComp"])
if stackKey.len() == 0 or stackKey == "-" or stackKey == "Unknown":
continue
stackResult(stackKey, stack, level, jsonLine)
bar.finish()
outputResult(output, "Computer", stack, isStackComputer=true)
stackKey = getJsonValue(x.Details, @["SrcComp"])
return (stackKey, @[])
let stack = processJSONL(eventFilter, getStackKey, totalLines, timeline, level)
outputResult(output, "Computer", stack, isMinColumns=true)
outputElapsedTime(startTime)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
proc stackIpaddresses(level: string = "informational", targetIpAddresses: bool = false, output: string = "", quiet: bool = false, timeline: string) =
proc stackIpAddresses(level: string = "informational", targetIpAddresses: bool = false, output: string = "", quiet: bool = false, timeline: string) =
let startTime = epochTime()
checkArgs(quiet, timeline, level)
let totalLines = countJsonlAndStartMsg("IpAddresses", "the IpAddress field as well as show alert information", timeline)
Expand Down

0 comments on commit fe7efcd

Please sign in to comment.