Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAPIDetectQuery(regex, attack, target, ip, method, header, path, date, lt, gt string) bson.M
- func BuildAPILogsQuery(id, ip, method, header, path, date, lt, gt string) bson.M
- func CheckAPIDetectParams(regex, attack, target, ip, method, header, path, date, lt, gt string) error
- func CheckAPILogsParams(id, ip, method, header, path, date, lt, gt string) error
- func GetAPIDetectQuery(req *http.Request) (bson.M, error)
- func GetAPILogsQuery(req *http.Request) (bson.M, error)
- func HealthHandler(w http.ResponseWriter, req *http.Request)
- func IPInfoHandler(w http.ResponseWriter, req *http.Request, dbName string, client *mongo.Client)
- func IsIntInTheRange(input string, start int, end int) (int, error)
- func LogsDetectHandler(w http.ResponseWriter, req *http.Request, dbName string, client *mongo.Client)
- func LogsHandler(w http.ResponseWriter, req *http.Request, dbName string, client *mongo.Client)
- func NotFoundHandler(w http.ResponseWriter, req *http.Request)
- func Server()
- func StatsDBHandler(w http.ResponseWriter, req *http.Request, dbName string, client *mongo.Client)
- func StatsHandler(w http.ResponseWriter, req *http.Request, dbName string, client *mongo.Client)
- func Top(w http.ResponseWriter, req *http.Request, dbName string, client *mongo.Client, ...) ([]string, error)
- type IPInfoResponse
Constants ¶
View Source
const ( ContextBackgroundDuration = 3 DayTime = time.Hour * 24 TopParamStart = 4 TopParamEnd = 50 )
View Source
const ( // This is the 'fallback' endpoint, when // a client tries to request a resource on an // endpoint that is not defined, this will be // the default response it will get. NotFound = "/" // This is the health status endpoint. // Performing a request to this endpoint the // client should receive a lightweight response // 'OK' with 200 as status code if everything is // behaving correctly. Health = "/api/health" // This endpoint is intended to serve a summary // of the information available for the IP taken // as input. // Parameter: top // Which info? Number of requests, timestamp of // the last activity, top X (default 10) // methods, path, headers. IPInfo = "/api/info/{ip}" // This endpoint is intended to serve information about // logs, so the requests were made to the Honeypot. // These are the parameters the endpoint accepts: // - id // - ip // - method // - header // - path // - date (YYYY-MM-DD) // - lt (less than YYYY-MM-DD-HH-MM-SS) // - gt (greater than YYYY-MM-DD-HH-MM-SS). APILogs = "api/logs" // This endpoint is intended to perform a heavy // and accurate scan on the logs. It takes as input // these parameters: // - regex (Go format) // - attack (use a list of well known regex) // - target (where to apply the regex) // - ip // - method // - header // - path // - date // - lt (less than YYYY-MM-DD-HH-MM-SS) // - gt (greater than YYYY-MM-DD-HH-MM-SS). APIDetect = "api/detect" // This endpoint gives a general overview of the system. APIStats = "api/stats" // This endpoint gives a detailed overview of the data // stored in the DB. APIStatsDB = "api/stats/db" )
Api routes.
View Source
const ( WriteTimeoutDuration = 15 ReadTimeoutDuration = 15 )
Variables ¶
View Source
var ( ErrPossibleTopValue = errors.New("possible values for top: method / path / body") ErrNoStatsIP = errors.New("no stats available for the specified IP") ErrIDDefined = errors.New("if id is defined, no other parameters need to be defined") ErrDateDefined = errors.New("if date is defined, lt and gt must be blank") ErrLtBeforeGt = errors.New("lt cannot be before gt") ErrHTTPMethodUnknown = errors.New("http method unknown") ErrInvalidIP = errors.New("ip address is not valid") ErrStringToIntConversion = errors.New("failed to convert string to int") ErrRetrievingData = errors.New("error while retrieving data") ErrIntegerRange = errors.New("integer not in the range") )
Functions ¶
func BuildAPIDetectQuery ¶
func BuildAPIDetectQuery(regex, attack, target, ip, method, header, path, date, lt, gt string) bson.M
BuildAPIDetectQuery.
func BuildAPILogsQuery ¶
BuildAPILogsQuery.
func CheckAPIDetectParams ¶
func CheckAPIDetectParams(regex, attack, target, ip, method, header, path, date, lt, gt string) error
CheckAPIDetectParams.
func CheckAPILogsParams ¶
CheckAPILogsParams.
func GetAPIDetectQuery ¶
GetAPIDetectQuery > - regex (Go format) - attack (use a list of well known regex) - target (where to apply the regex) - ip - method - header - path - date - lt (less than YYYY-MM-DD-HH-MM-SS) - gt (greater than YYYY-MM-DD-HH-MM-SS).
func GetAPILogsQuery ¶
GetAPILogsQuery > - id - ip - method - header - path - date (YYYY-MM-DD) - lt (less than YYYY-MM-DD-HH-MM-SS) - gt (greater than YYYY-MM-DD-HH-MM-SS).
func HealthHandler ¶
func HealthHandler(w http.ResponseWriter, req *http.Request)
HealthHandler tells you if the API server is listening.
func IPInfoHandler ¶
IPInfoHandler.
func IsIntInTheRange ¶
IsIntInTheRange.
func LogsDetectHandler ¶
func LogsDetectHandler(w http.ResponseWriter, req *http.Request, dbName string, client *mongo.Client)
LogsDetectHandler.
func LogsHandler ¶
LogsHandler.
func NotFoundHandler ¶
func NotFoundHandler(w http.ResponseWriter, req *http.Request)
NotFoundHandler tells you if the API server is listening.
func StatsDBHandler ¶
StatsDBHandler.
func StatsHandler ¶
StatsHandler.
Types ¶
Click to show internal directories.
Click to hide internal directories.