Documentation
¶
Index ¶
Constants ¶
const ( MissingRequestParam = "Missing 'request' query parameter" InvalidInput = "Invalid input" FailedToEncodeResponse = "Failed to encode response" KasperskyUnexpectedError = "Kaspersky API returned unexpected error" BadRequestMsg = "Bad Request: Incorrect query." InternalServerErrorMsg = "Internal Server Error" ScanFileBadRequestMsg = "Bad Request: Failed to process the uploaded file." ScanFilePayloadTooLargeMsg = "Payload Too Large: File size exceeds the 256 MB limit." ScanFileInternalServerErrorMsg = "Internal Server Error: Unable to process the file." )
const ( MB = 1 << 20 MaxUploadSize = 256 * MB )
Variables ¶
This section is empty.
Functions ¶
func RespondWithJSON ¶
func RespondWithJSON(w http.ResponseWriter, statusCode int, data interface{})
RespondWithJSON отправляет ответ с данными в формате JSON
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) DomainIPUrl ¶
func (h *Handler) DomainIPUrl(w http.ResponseWriter, r *http.Request)
DomainIPUrl @Summary Проверка веб-адреса, IP или домена через Kaspersky API @Description Эндпоинт для проверки веб-адреса, IP или домена и получения объединенного ответа с информацией из Kaspersky API. В зависимости от типа входных данных (IPv4, URL или домен), возвращаются соответствующие поля в ответе. @ID domain-check @Tags Scan @Accept json @Produce json @Param request query string true "Веб-адрес, IP или домен для проверки" example(www.example.com) @Success 200 {object} models.ResponseFromAPI "Успешная проверка. Возвращается объединенный ответ с информацией." @Failure 400 {object} common.ErrorResponse "Bad Request: Incorrect query." @Failure 404 {object} common.ErrorResponse "Not Found: Lookup results not found." @Failure 500 {object} common.ErrorResponse "Internal Server Error"
@Example 200 Success { "Zone": "Green", "Categories": ["CATEGORY_INFORMATION_TECHNOLOGIES", "CATEGORY_SEARCH_ENGINES_AND_SERVICES"], "CategoriesWithZone": [ { "Name": "CATEGORY_INFORMATION_TECHNOLOGIES", "Zone": "Grey" }, { "Name": "CATEGORY_SEARCH_ENGINES_AND_SERVICES", "Zone": "Grey" } ], "DomainGeneralInfo": { "FilesCount": 1000, "UrlsCount": 100000, "HitsCount": 1000000, "Domain": "ya.ru", "Ipv4Count": 205, "Categories": ["CATEGORY_INFORMATION_TECHNOLOGIES", "CATEGORY_SEARCH_ENGINES_AND_SERVICES"], "CategoriesWithZone": [ { "Name": "CATEGORY_INFORMATION_TECHNOLOGIES", "Zone": "Grey" }, { "Name": "CATEGORY_SEARCH_ENGINES_AND_SERVICES", "Zone": "Grey" } ] }, "DomainWhoIsInfo": { "DomainName": "ya.ru", "Created": "1999-07-11T20:00:00Z", "Updated": "2021-01-01T00:00:00Z", "Expires": "2025-07-30T21:00:00Z", "NameServers": ["ns1.yandex.ru", "ns2.yandex.ru"], "Contacts": [ { "ContactType": "registrant", "Organization": "YANDEX, LLC." } ], "Registrar": { "Info": "RU-CENTER-RU", "IanaId": "1234" }, "DomainStatus": ["REGISTERED, DELEGATED, VERIFIED"], "RegistrationOrganization": "RU-CENTER-RU" } } @Example 400 Bad Request { "Message": "Invalid input" } @Example 404 Not Found { "Message": "Not Found: Lookup results not found." } @Example 500 Internal Server Error { "Message": "Internal Server Error" }
@Router /api/scan/uri [get]
func (*Handler) ScanFile ¶
func (h *Handler) ScanFile(w http.ResponseWriter, r *http.Request)
ScanFile @Summary Сканирует файл с использованием API Kaspersky @Description Эндпоинт для сканирования файла и получения базового отчета от API Kaspersky. @ID file-scan @Tags Scan @Accept multipart/form-data @Produce json @Param file formData file true "File to scan" @Success 200 {object} models.FileScanResponse "Successful scan. Returns basic information about the analyzed file." @Failure 400 {object} common.ErrorResponse "Bad Request: Failed to process the uploaded file." @Failure 401 {object} common.ErrorResponse "Unauthorized: Authentication failed." @Failure 413 {object} common.ErrorResponse "Payload Too Large: File size exceeds the 256 Mb limit." @Failure 500 {object} common.ErrorResponse "Internal Server Error: Unable to process the file."
@Example 200 Success { "Zone": "Red", "FileGeneralInfo": { "FileStatus": "Malware", "Sha1": "abc123...", "Md5": "def456...", "Sha256": "ghi789...", "FirstSeen": "2022-01-01T00:00:00Z", "LastSeen": "2022-10-01T00:00:00Z", "Size": 123456, "Type": "Executable", "HitsCount": 100 }, "DetectionsInfo": [ { "LastDetectDate": "2022-10-01T00:00:00Z", "DescriptionUrl": "https://threats.kaspersky.com/en/threat/DetectedObject", "Zone": "Red", "DetectionName": "Trojan.Win32.Malware", "DetectionMethod": "Signature" } ], "DynamicDetections": [ { "Zone": "Red", "Threat": 1 } ] } @Example 400 Bad Request { "Message": "Неверный запрос: Не удалось обработать загруженный файл." } @Example 401 Unauthorized { "Message": "Неавторизован: Ошибка аутентификации." } @Example 413 Payload Too Large { "Message": "Слишком большой размер данных: Размер файла превышает 256 МБ." } @Example 500 Internal Server Error { "Message": "Внутренняя ошибка сервера: Не удалось обработать файл." }
@Router /api/scan/file [post]
func (*Handler) ScanScreen ¶
func (h *Handler) ScanScreen(w http.ResponseWriter, r *http.Request)
ScanScreen @Summary Проверка веб-адреса, IP или домена из изображения через Kaspersky API @Description Эндпоинт для загрузки изображения, извлечения текста, поиска веб-адресов, IP и доменов, и получения ответа с информацией из Kaspersky API. В зависимости от типа входных данных (IPv4, URL или домен), возвращаются соответствующие поля в ответе. @ID screen-check @Tags Scan @Accept multipart/form-data @Produce json @Param file formData file true "Изображение, содержащее веб-адрес, IP или домен для проверки" @Success 200 {object} map[string]models.ResponseFromAPI "Успешная проверка. Возвращается объединенный ответ с информацией." @Failure 400 {object} common.ErrorResponse "Bad Request: Incorrect file upload or processing error." @Failure 413 {object} common.ErrorResponse "Payload Too Large: File size exceeds the limit." @Failure 404 {object} common.ErrorResponse "Not Found: Lookup results not found." @Failure 500 {object} common.ErrorResponse "Internal Server Error"
@Example 400 Bad Request
{ "Message": "Invalid input" }
@Example 404 Not Found
{ "Message": "Not Found: Lookup results not found." }
@Example 500 Internal Server Error
{ "Message": "Internal Server Error" }
@Router /api/scan/screen [post]