botherder/viper — pull request #127 by deralexxx (2014-08-28 13:12:05+00:00)
Title: [API] /file/tags/add

Have improved that: https://github.com/botherder/viper/pull/91/files - I hope that is better and will be accepted

Should now be much more flexible, you can add tags to the same search criterias like file searched. You can also add tags to multiple files by searching for files by tags:

/scripts/viper$ curl -F file=@testfile -F tags="foo" --noproxy localhost localhost:8080/file/add
{
"message": "added"

/scripts/viper$curl -F md5="d41d8cd98f00b204e9800998ecf8427e" --noproxy localhost localhost:8080/file/find
[
{
"sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"name": "testfile",
"tags": [
"foo"
],
"sha512": "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
"created_at": "2014-08-28 14:54:18.983771",
"crc32": "00000000",
"ssdeep": "",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"type": "empty",
"id": 8,
"md5": "d41d8cd98f00b204e9800998ecf8427e",
"size": 0
}
]

/scripts/viper$ curl -Ffile=@testfile2 -F tags="foobar" --noproxy localhost localhost:8080/file/addd
{
"message": "added"
}

/scripts/viper$ curl -F tag="foobar" --noproxy localhost localhost:8080/file/find
[
{
"sha1": "efb445db9a2edc3a4142b89cfe2a067d236811fb",
"name": "testfile2",
"tags": [
"foobar"
],
"sha512": "45f379fb0de766ebf656e83de8bc80751edd46091593d52e41bb227bbf73bd03ea09acbadb5ae57b6e5cdc5dff38de8e1423a3210fb50854a909a9c772ffe193",
"created_at": "2014-08-28 14:54:18.983771",
"crc32": "65C0371F",
"ssdeep": "",
"sha256": "61b4c705859f4158d38090c1e38e8fdc4f3d29db007f012766276aa498835cf6",
"type": "ASCII text",
"id": 9,
"md5": "e1930b4927e6b6d92d120c7c1bba3421",
"size": 7
}
]

/scripts/viper$curl -F md5="e1930b4927e6b6d92d120c7c1bba3421" -F tags="bar2" --noproxy localhost localhost:8080/file/tags/add
{
"message": "added"
}

/scripts/viper$ curl -Ftag="foobar" --noproxy localhost localhost:8080/file/find
[
{
"sha1": "efb445db9a2edc3a4142b89cfe2a067d236811fb",
"name": "testfile2",
"tags": [
"foobar",
"bar2"
],
"sha512": "45f379fb0de766ebf656e83de8bc80751edd46091593d52e41bb227bbf73bd03ea09acbadb5ae57b6e5cdc5dff38de8e1423a3210fb50854a909a9c772ffe193",
"created_at": "2014-08-28 14:54:18.983771",
"crc32": "65C0371F",
"ssdeep": "",
"sha256": "61b4c705859f4158d38090c1e38e8fdc4f3d29db007f012766276aa498835cf6",
"type": "ASCII text",
"id": 9,
"md5": "e1930b4927e6b6d92d120c7c1bba3421",
"size": 7
}
]

/scripts/viper$ curl -Fmd5="d41d8cd98f00b204e9800998ecf8427e" -F tags="bar2" --noproxy localhost localhost:8080/file/tags/add
{
"message": "added"
}

/scripts/viper$ curl -F md5="d41d8cd98f00b204e9800998ecf8427e" -F tags="bar2" --noproxy localhost localhost:8080/file/find
[
{
"sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"name": "testfile",
"tags": [
"foo",
"bar2"
],
"sha512": "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
"created_at": "2014-08-28 14:54:18.983771",
"crc32": "00000000",
"ssdeep": "",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"type": "empty",
"id": 8,
"md5": "d41d8cd98f00b204e9800998ecf8427e",
"size": 0
}
]

/scripts/viper$ curl -F tags="viper is awesome" -F tag="bar2" --noproxy localhost localhost:8080/file/tags/add
{
"message": "added"
}

/scripts/viper$ curl -Fmd5="d41d8cd98f00b204e9800998ecf8427e" -F tags="bar2" --noproxy localhost localhost:8080/file/find
[
{
"sha1": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"name": "testfile",
"tags": [
"foo",
"bar2",
"viper",
"is",
"awesome"
],
"sha512": "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
"created_at": "2014-08-28 14:54:18.983771",
"crc32": "00000000",
"ssdeep": "",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"type": "empty",
"id": 8,
"md5": "d41d8cd98f00b204e9800998ecf8427e",
"size": 0
}
]