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

README.md incomplete / inaccurate #28

Open
corey-Robinson1337 opened this issue Jan 3, 2022 · 8 comments
Open

README.md incomplete / inaccurate #28

corey-Robinson1337 opened this issue Jan 3, 2022 · 8 comments

Comments

@corey-Robinson1337
Copy link

Following the instructions for the setup exactly produces the error --

image

@bsurmanski
Copy link
Collaborator

A 400 error is a client error. It's possible a step may have been missed in set up.

Did you follow the set up at: https://cloud.google.com/web-risk/docs/quickstarts
to enable the webrisk API for the cloud project associated with that API key?

@corey-Robinson1337
Copy link
Author

corey-Robinson1337 commented Jan 3, 2022

Yes I'm having no issues hitting the webrisk api with that key!

image

I've also made sure that $APIKEY has the correct value

@bsurmanski
Copy link
Collaborator

bsurmanski commented Jan 4, 2022

A few things to check:

  1. try modifying netAPI::doRequest in api.go to print the full error message from the request, not just the http status code. This line here:

    webrisk/api.go

    Line 96 in 030b4b9

    return fmt.Errorf("webrisk: unexpected server response code: %d", httpResp.StatusCode)

  2. Looks like your first error reported is 'no database file specified'. This might have cascaded the further errors. See if specifying the -db flag changes anything.

  3. I believe uris:search is part of the lookup API. It's possible there's a setup difference. Consider trying a curl of one of the methods from the Update API: https://cloud.google.com/web-risk/docs/update-api.

  4. check the wrlookup command to see if it also gives a 400 error, since it seems using curl succeeds for that command.

@corey-Robinson1337
Copy link
Author

image
3.
Running the sample request returns expected response

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
""https://webrisk.googleapis.com/v1/threatLists:computeDiff?threatType=MALWARE&versionToken=Gg4IBBADIgYQgBAiAQEoAQ%3D%3D&constraints.maxDiffEntries=2048&constraints.maxDatabaseEntries=4096&constraints.supportedCompressions=RAW""

image

image

For Issue one I'm not really familiar with Go. Should I make the change then run go install?

What should httpResp.StatusCode be changed to to output the appropriate error message?

@bsurmanski
Copy link
Collaborator

Looks like wrlookup is having problems too.

I'm on mobile rn, so can't double check, but I think the best way to modify and run the webrisk server would be to checkout the git repo, make the change, then run go run or whatever the command is. I think it would be something like go run cmd/wrserver/main.go in the webrisk directory

@corey-Robinson1337
Copy link
Author

alright I changed the line

from

 return fmt.Errorf("webrisk: unexpected server response code: %d", httpResp.StatusCode) 

to

 return fmt.Errorf("webrisk: unexpected server response code: %d", httpResp)

and ran the main.go script as you instructed

image

@bsurmanski
Copy link
Collaborator

Ahhh, I think i see the issue. I believe the API key is set incorrectly. I imagine print-access-token would give you, well, some sort of access token. Maybe oauth. But this WebRisk CLI uses API keys. I think the WebRisk API can use both access token and api key, which is why it worked with curl; but this client in this repo specifically uses api keys right now.

View your api keys by visiting the Google cloud console: https://console.cloud.google.com/apis/credentials

Make sure the API restrictions allow webrisk.

@corey-Robinson1337
Copy link
Author

Yeah that was it.

Perhaps the README should be updated with instructions on how to generate the api key for this sample app because if you follow the setup here https://cloud.google.com/web-risk/docs/using-sample-app

you will be instructed to first read the general setup which links to here

A brief walkthrough of how to generate the key needed for this particular project would have been very useful. Probably more useful than the entire existing quickstart guide.

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

No branches or pull requests

2 participants