Skip to content

Commit bdba4ce

Browse files
committed
malware for file hash endpoint
1 parent c245523 commit bdba4ce

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export(xforce_as_networks)
44
export(xforce_ip_history)
55
export(xforce_ip_malware)
66
export(xforce_ip_report)
7+
export(xforce_malware_for_hash)
78
export(xforce_resolve)
89
export(xforce_url_malware)
910
export(xforce_url_report)

R/malware-hash.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#' Get Malware for File Hash
2+
#'
3+
#' @md
4+
#' @param hash file hash
5+
#' @param api_key,api_password IBM X-Force API Key & Password. All `xforce`
6+
#' API functions will look for these in the `XFORCE_API_KEY` and
7+
#' `XFORCE_API_PASSWORD` environment variables. You can store these
8+
#' in `~/.Renviron` and you can obtain them
9+
#' [on the IBM X-Force Portal](api_key=Sys.getenv("XFORCE_API_KEY")).
10+
#' @export
11+
#' @examples \donrun{
12+
#' xforce_ip_history("174.62.167.97")
13+
#' }
14+
xforce_malware_for_hash <- function(hash, api_key=Sys.getenv("XFORCE_API_KEY"),
15+
api_password=Sys.getenv("XFORCE_API_PASSWORD")) {
16+
17+
httr::GET(
18+
url = sprintf("https://api.xforce.ibmcloud.com/malware/%s", hash),
19+
httr::accept_json(),
20+
httr::user_agent("R xforce package (https://github.com/hrbrmstr/xforce"),
21+
httr::authenticate(
22+
user = api_key,
23+
password = api_password
24+
)
25+
) -> res
26+
27+
httr::stop_for_status(res)
28+
29+
out <- httr::content(res, as = "text")
30+
31+
out <- jsonlite::fromJSON(out)
32+
33+
out
34+
35+
}

README.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The following functions are implemented:
2121
- `xforce_ip_history`: Get IP History
2222
- `xforce_ip_malware`: Get Malware Associated with the IP
2323
- `xforce_ip_report`: Get IP Report
24+
- `xforce_malware_for_hash`: Get Malware for File Hash
2425
- `xforce_resolve`: Get DNS Records
2526
- `xforce_url_malware`: Get Malware for URL
2627
- `xforce_url_report`: Get URL Report

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The following functions are implemented:
2424
- `xforce_ip_history`: Get IP History
2525
- `xforce_ip_malware`: Get Malware Associated with the IP
2626
- `xforce_ip_report`: Get IP Report
27+
- `xforce_malware_for_hash`: Get Malware for File Hash
2728
- `xforce_resolve`: Get DNS Records
2829
- `xforce_url_malware`: Get Malware for URL
2930
- `xforce_url_report`: Get URL Report

man/xforce_malware_for_hash.Rd

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)