Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Nov 11, 2016
1 parent 51ae404 commit 227db64
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 61 deletions.
23 changes: 0 additions & 23 deletions Dockerfile.dev

This file was deleted.

2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ dev:
docker run --rm $(NAME):dev $(DEV_RUN_OPTS)

build:
rm -rf build && mkdir build
docker build -t $(NAME):$(VERSION) .
sed -i.bu 's/docker image-.*-blue/docker image-$(shell docker images --format "{{.Size}}" $(NAME):$(VERSION))-blue/g' README.md
docker save $(NAME):$(VERSION) | gzip -9 > build/$(NAME)_$(VERSION).tgz

release:
rm -rf release && mkdir release
Expand Down
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ Commands:
Run 'virustotal COMMAND --help' for more information on a command.
```

This will output to stdout and POST to malice results API webhook endpoint.
Sample Output
-------------

### Sample Output JSON:
### JSON:

```json
{
Expand Down Expand Up @@ -157,7 +158,7 @@ This will output to stdout and POST to malice results API webhook endpoint.
}
```

### Sample Output STDOUT (Markdown Table):
### STDOUT (Markdown Table):

---

Expand All @@ -169,20 +170,33 @@ This will output to stdout and POST to malice results API webhook endpoint.

---

Documentation
-------------

### To write results to [ElasticSearch](https://www.elastic.co/products/elasticsearch)

```bash
$ docker volume create --name malice
$ docker run -d -p 9200:9200 -v malice:/data --name elastic elasticsearch
$ docker run --rm --link elastic malice/virustotal --api APIKEY lookup HASH
$ docker run -d --name elastic \
-p 9200:9200 \
-v malice:/usr/share/elasticsearch/data \
blacktop/elasticsearch
$ docker run --rm --link elastic malice/virustotal HASH
```

### Documentation

### Issues

Find a bug? Want more features? Find something missing in the documentation? Let me know! Please don't hesitate to [file an issue](https://github.com/maliceio/malice-virustotal/issues/new) and I'll get right on it.

### CHANGELOG

See [`CHANGELOG.md`](https://github.com/maliceio/malice-virustotal/blob/master/CHANGELOG.md)

### Contributing

[See all contributors on GitHub](https://github.com/maliceio/malice-virustotal/graphs/contributors).

Please update the [CHANGELOG.md](https://github.com/maliceio/malice-virustotal/blob/master/CHANGELOG.md) and submit a [Pull Request on GitHub](https://help.github.com/articles/using-pull-requests/).

### ToDo

- [ ] Add docs like [registrator](http://gliderlabs.com/registrator/latest/#getting-registrator)
Expand Down
13 changes: 7 additions & 6 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ machine:
- docker

dependencies:
pre:
- make circleci
cache_directories:
- "~/docker"
override:
- make build
post:
- cp build/* $CIRCLE_ARTIFACTS
- docker info
- if [[ -e ~/docker/image.tar ]]; then docker load --input ~/docker/image.tar; fi
- docker build -t malice_vt .
- mkdir -p ~/docker; docker save malice_vt > ~/docker/image.tar

test:
override:
- /bin/true
- docker run malice_vt --help

deployment:
# master:
Expand Down
38 changes: 16 additions & 22 deletions virustotal.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ func main() {
app.Version = Version + ", BuildTime: " + BuildTime
app.Compiled, _ = time.Parse("20060102", BuildTime)
app.Usage = "Malice VirusTotal Plugin"
var apikey string
var elasitcsearch string
var table bool
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "verbose, V",
Expand All @@ -294,23 +291,20 @@ func main() {
EnvVar: "MALICE_PROXY",
},
cli.BoolFlag{
Name: "table, t",
Usage: "output as Markdown table",
Destination: &table,
Name: "table, t",
Usage: "output as Markdown table",
},
cli.StringFlag{
Name: "api",
Value: "",
Usage: "VirusTotal API key",
EnvVar: "MALICE_VT_API",
Destination: &apikey,
Name: "api",
Value: "",
Usage: "VirusTotal API key",
EnvVar: "MALICE_VT_API",
},
cli.StringFlag{
Name: "elasitcsearch",
Value: "",
Usage: "elasitcsearch address for Malice to store results",
EnvVar: "MALICE_ELASTICSEARCH",
Destination: &elasitcsearch,
Name: "elasitcsearch",
Value: "",
Usage: "elasitcsearch address for Malice to store results",
EnvVar: "MALICE_ELASTICSEARCH",
},
}
app.Commands = []cli.Command{
Expand All @@ -321,7 +315,7 @@ func main() {
ArgsUsage: "FILE to upload to VirusTotal",
Action: func(c *cli.Context) error {
// Check for valid apikey
if apikey == "" {
if c.String("api") == "" {
log.Fatal(fmt.Errorf("Please supply a valid VT_API key with the flag '--api'."))
}
if c.Bool("verbose") {
Expand All @@ -334,7 +328,7 @@ func main() {
utils.Assert(err)
}
// upload file to virustotal.com
scanFile(path, apikey)
scanFile(path, c.String("api"))
} else {
log.Fatal(fmt.Errorf("Please supply a file to upload to VirusTotal."))
}
Expand All @@ -348,7 +342,7 @@ func main() {
ArgsUsage: "MD5/SHA1/SHA256 hash of file",
Action: func(c *cli.Context) error {
// Check for valid apikey
if apikey == "" {
if c.String("api") == "" {
log.Fatal(fmt.Errorf("Please supply a valid VT_API key with the flag '--api'."))
}
if c.Bool("verbose") {
Expand All @@ -357,18 +351,18 @@ func main() {

if c.Args().Present() {
hash := c.Args().First()
vtReport := lookupHash(hash, apikey)
vtReport := lookupHash(hash, c.String("api"))

// upsert into Database
elasticsearch.InitElasticSearch()
elasticsearch.InitElasticSearch(c.String("elasitcsearch"))
elasticsearch.WritePluginResultsToDatabase(elasticsearch.PluginResults{
ID: utils.Getopt("MALICE_SCANID", hash),
Name: name,
Category: category,
Data: vtReport,
})

if table {
if c.Bool("table") {
printMarkDownTable(vtReport)
} else {
vtJSON, err := json.Marshal(vtReport)
Expand Down

0 comments on commit 227db64

Please sign in to comment.