chg: [API] add Tracker documentation

pull/396/head v2.2
Terrtia 2019-09-13 11:40:09 +02:00
parent fb35be77f4
commit 5734205828
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 69 additions and 32 deletions

View File

@ -748,10 +748,13 @@ curl https://127.0.0.1:7000/api/v1/get/cryptocurrency/bitcoin/item --header "Aut
### Add term tracker: `api/v1/add/tracker/term`<a name="add_term_tracker"></a> ### Add term tracker: `api/v1/add/tracker`<a name="add_tracker"></a>
#### Description #### Description
Add term tracker Create a new tracker (word, set, regex).
You need to use a regex if you want to use one of the following special characters [<>~!?@#$%^&*|()_-+={}\":;,.\'\n\r\t]/\\
**Method** : `POST` **Method** : `POST`
@ -788,13 +791,24 @@ Add term tracker
#### Example #### Example
``` ```
curl https://127.0.0.1:7000/api/v1/add/tracker/term --header "Authorization: iHc1_ChZxj1aXmiFiF1mkxxQkzawwriEaZpPqyTQj " -H "Content-Type: application/json" --data @input.json -X POST curl https://127.0.0.1:7000/api/v1/add/tracker --header "Authorization: iHc1_ChZxj1aXmiFiF1mkxxQkzawwriEaZpPqyTQj " -H "Content-Type: application/json" --data @input.json -X POST
``` ```
#### input.json Example #### input.json Example
```json ```json
{ {
"term": "test test2 test3",
"type": "set",
"nb_words": 2,
"tags": [
"mytags",
"othertags"
],
"mails": [
"mail@mail.test",
"othermail@mail.test"
],
"level": 1
} }
``` ```
@ -803,24 +817,31 @@ curl https://127.0.0.1:7000/api/v1/add/tracker/term --header "Authorization: iHc
```json ```json
{ {
"uuid": "6a16b06e-38e5-41e1-904d-3960610647e8"
} }
``` ```
#### Expected Fail Response #### Expected Fail Response
**HTTP Status Code** : `400` **HTTP Status Code** : 400
```json ```json
{"status": "error", "reason": "Term not provided"}
{"status": "error", "reason": "Term type not provided"}
{"status": "error", "reason": "special character not allowed", "message": "Please use a regex or remove all special characters"}
{"status": "error", "reason": "Incorrect type"}
```
**HTTP Status Code** : 409
```json
{"status": "error", "reason": "Term already tracked"}
``` ```
### Delete term tracker: `api/v1/delete/tracker`<a name="delete_tracker"></a>
### Delete term tracker: `api/v1/delete/tracker/term`<a name="delete_term_tracker"></a>
#### Description #### Description
Delete term tracker Delete a tracker
**Method** : `DELETE` **Method** : `DELETE`
@ -837,13 +858,13 @@ Delete term tracker
#### Example #### Example
``` ```
curl https://127.0.0.1:7000/api/v1/add/tracker/term --header "Authorization: iHc1_ChZxj1aXmiFiF1mkxxQkzawwriEaZpPqyTQj " -H "Content-Type: application/json" --data @input.json -X POST curl https://127.0.0.1:7000/api/v1/delete/tracker --header "Authorization: iHc1_ChZxj1aXmiFiF1mkxxQkzawwriEaZpPqyTQj " -H "Content-Type: application/json" --data @input.json -X POST
``` ```
#### input.json Example #### input.json Example
```json ```json
{ {
"uuid": "6a16b06e-38e5-41e1-904d-3960610647e8"
} }
``` ```
@ -852,7 +873,7 @@ curl https://127.0.0.1:7000/api/v1/add/tracker/term --header "Authorization: iHc
```json ```json
{ {
"uuid": "6a16b06e-38e5-41e1-904d-3960610647e8"
} }
``` ```
@ -860,17 +881,22 @@ curl https://127.0.0.1:7000/api/v1/add/tracker/term --header "Authorization: iHc
**HTTP Status Code** : `400` **HTTP Status Code** : `400`
```json ```json
{"status": "error", "reason": "Invalid uuid"}
```
**HTTP Status Code** : `404`
```json
({"status": "error", "reason": "Unknown uuid"}
``` ```
### Delete term tracker: `api/v1/get/tracker/item`<a name="get_tracker_item"></a>
### Delete term tracker: `api/v1/delete/tracker/term/item`<a name="delete_term_tracker"></a>
#### Description #### Description
Delete term tracker Get tracked items by date-range
**Method** : `POST` **Method** : `POST`
@ -904,29 +930,40 @@ Delete term tracker
#### Example #### Example
``` ```
curl https://127.0.0.1:7000/api/v1/add/tracker/term --header "Authorization: iHc1_ChZxj1aXmiFiF1mkxxQkzawwriEaZpPqyTQj " -H "Content-Type: application/json" --data @input.json -X POST curl https://127.0.0.1:7000/api/v1/get/tracker/item --header "Authorization: iHc1_ChZxj1aXmiFiF1mkxxQkzawwriEaZpPqyTQj " -H "Content-Type: application/json" --data @input.json -X POST
``` ```
#### input.json Example #### input.json Example
```json ```json
{ {
"uuid": "6a16b06e-38e5-41e1-904d-3960610647e8",
"date_from": "20190823",
"date_to": "20190829",
"items": [
{
"id": "submitted/2019/08/25/4f929998-3921-4be3-b448-be3bf1722d6b.gz",
"date": 20190825,
"tags": [
"infoleak:automatic-detection=\"credential\"",
"mytags",
"othertags",
]
}
]
} }
``` ```
#### Expected Success Response
**HTTP Status Code** : `200`
```json
{
}
```
#### Expected Fail Response
**HTTP Status Code** : `400` **HTTP Status Code** : `400`
```json ```json
{"status": "error", "reason": "Invalid uuid"}
```
**HTTP Status Code** : `404`
```json
({"status": "error", "reason": "Unknown uuid"}
``` ```

View File

@ -317,7 +317,7 @@ def get_all_tags():
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # TRACKER # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # TRACKER # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@restApi.route("api/v1/add/tracker/term", methods=['POST']) @restApi.route("api/v1/add/tracker", methods=['POST'])
@token_required('analyst') @token_required('analyst')
def add_tracker_term(): def add_tracker_term():
data = request.get_json() data = request.get_json()
@ -326,7 +326,7 @@ def add_tracker_term():
res = Term.parse_json_term_to_add(data, user_id) res = Term.parse_json_term_to_add(data, user_id)
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1] return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
@restApi.route("api/v1/delete/tracker/term", methods=['DELETE']) @restApi.route("api/v1/delete/tracker", methods=['DELETE'])
@token_required('analyst') @token_required('analyst')
def delete_tracker_term(): def delete_tracker_term():
data = request.get_json() data = request.get_json()
@ -335,7 +335,7 @@ def delete_tracker_term():
res = Term.parse_tracked_term_to_delete(data, user_id) res = Term.parse_tracked_term_to_delete(data, user_id)
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1] return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
@restApi.route("api/v1/get/tracker/term/item", methods=['POST']) @restApi.route("api/v1/get/tracker/item", methods=['POST'])
@token_required('analyst') @token_required('analyst')
def get_tracker_term_item(): def get_tracker_term_item():
data = request.get_json() data = request.get_json()