Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip/lapi] cscli http debug #278

Merged
merged 2 commits into from Oct 1, 2020
Merged

Conversation

buixor
Copy link
Contributor

@buixor buixor commented Oct 1, 2020

  • cscli with --debug will provide extra info on outgoing HTTP requests.
  • cscli with --trace will print HTTP requests/responses
$ ./cmd/crowdsec-cli/cscli decisions list --debug
...
DEBU[0000] req-jwt: GET http://localhost:8080/alerts/?has_active_decision=true 
DEBU[0000] resp-jwt: 301                                
DEBU[0000] req-jwt: GET http://localhost:8080/alerts?has_active_decision=true 
DEBU[0000] resp-jwt: 200                                
+----+----------+--------------+-------------------------------------------+--------+---------+----+--------+---------------------------+
| ID |  SOURCE  | SCOPE:VALUE  |                  REASON                   | ACTION | COUNTRY | AS | EVENTS |        CREATED AT         |

$ ./cmd/crowdsec-cli/cscli decisions list --trace
...
TRAC[0000] req-jwt(auth): POST /watchers/login HTTP/1.1
Host: localhost:8080
Content-Type: application/json

{"machine_id":"82929df7ee39....arios":null} 
TRAC[0000] resp-api: HTTP/1.1 200 OK
Content-Length: 248
Content-Type: application/json; charset=utf-8
Date: Thu, 01 Oct 2020 08:29:02 GMT

{"code":2...k"} 
DEBU[0000] req-jwt: GET http://localhost:8080/alerts/?has_active_decision=true 
TRAC[0000] req-jwt: GET /alerts/?has_active_decision=true HTTP/1.1
Host: localhost:8080
Authorization: Bea...
User-Agent: crowdsec-v0.3.3-7c7d033b9305403849879bd542947741f8522e0b
 
TRAC[0000] resp-jwt: HTTP/1.1 301 Moved Permanently
Content-Length: 67
Content-Type: text/html; charset=utf-8
Date: Thu, 01 Oct 2020 08:29:02 GMT
Location: /alerts?has_active_decision=true

<a href="/alerts?has_active_decision=true">Moved Permanently</a>.
 
DEBU[0000] resp-jwt: 301                                
DEBU[0000] req-jwt: GET http://localhost:8080/alerts?has_active_decision=true 
TRAC[0000] req-jwt: GET /alerts?has_active_decision=true HTTP/0.0
Host: localhost:8080
Authorization: Be...
Referer: http://localhost:8080/alerts/?has_active_decision=true
User-Agent: crowdsec-v0.3.3-7c7d033b9305403849879bd542947741f8522e0b
 
TRAC[0000] resp-jwt: HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Date: Thu, 01 Oct 2020 08:29:02 GMT

20a7
[{"c...+0200"}]
0
 
DEBU[0000] resp-jwt: 200                                
+----+----------+--------------+-------------------------------------------+--------+---------+----+--------+---------------------------+
| ID |  SOURCE  | SCOPE:VALUE  |                  REASON                   | ACTION | COUNTRY | AS | EVENTS |        CREATED AT         |
+----+----------+--------------+-------------------------------------------+--------+---------+----+--------+---------------------------+
|  1 | crowdsec | Ip:127.0.0.1 | crowdsecurity/http-bad-user-agent         | ban    |         |    |      2 | 2020-10-01T09:14:09+02:00 |

Copy link
Contributor

@registergoofy registergoofy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@registergoofy registergoofy merged commit 2058e37 into wip_lapi Oct 1, 2020
@registergoofy registergoofy deleted the wip_lapi_cscli_http_debug branch October 1, 2020 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants