Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alex27riva committed Dec 3, 2024
1 parent b9864fc commit 992e1b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cmd/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ package cmd

import (
"fmt"
"github.com/fatih/color"
"github.com/rodaine/table"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"log"
"os"
"soc-cli/internal/apis"
"soc-cli/internal/util"
"strings"
"time"

"github.com/fatih/color"
"github.com/rodaine/table"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var reportLimit = 3
Expand Down Expand Up @@ -69,9 +72,9 @@ func analyzeIP(ip string) {

classification := greyNoiseData.Classification
if classification == "malicious" {
classification = color.RedString(classification)
classification = color.RedString(strings.ToUpper(classification))
} else if classification == "benign" {
classification = color.GreenString(classification)
classification = color.GreenString(strings.ToUpper(classification))
}

fmt.Printf("Noise: %v\nRiot: %v\nClassification: %s\nName: %s\nLink: %s\n",
Expand All @@ -84,11 +87,13 @@ func analyzeIP(ip string) {
fmt.Println("No reports found for this IP address")
return
}
// Parse date from string
lastReportDate, _ := time.Parse(time.RFC3339, abuseIPDBData.Data.LastReportedAt)

// Print AbuseIPDB info
fmt.Printf("Abuse Confidence Score: %d\n", abuseIPDBData.Data.AbuseConfidenceScore)
fmt.Printf("Total Reports: %d\n", abuseIPDBData.Data.TotalReports)
fmt.Printf("Last Reported At: %s\n", abuseIPDBData.Data.LastReportedAt)
fmt.Printf("Last Reported At: %s\n", lastReportDate.Format("Monday, January 2, 2006"))

// Print the individual reports if available
if len(abuseIPDBData.Data.Reports) > 0 {
Expand All @@ -111,6 +116,7 @@ func analyzeIP(ip string) {

} else {
color.Red("An error has occured.")
os.Exit(1)
}

}
Expand Down
1 change: 1 addition & 0 deletions cmd/whois.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var whoisCmd = &cobra.Command{
whoisData, err := apis.GetWhoisData(target)
if err != nil {
color.Red("An error has occured.")
os.Exit(1)
} else {
displayData(*whoisData)

Expand Down

0 comments on commit 992e1b0

Please sign in to comment.