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

Non-persistent mode expects database to be present #43

Closed
inge4pres opened this issue Jan 4, 2017 · 3 comments
Closed

Non-persistent mode expects database to be present #43

inge4pres opened this issue Jan 4, 2017 · 3 comments

Comments

@inge4pres
Copy link

inge4pres commented Jan 4, 2017

Hi,

I am trying to use this configuration to create a client

mykey := os.Getenv("SB_KEY")
conf := &sb.Config{
		APIKey:    mykey,
		Logger:    os.Stdout,
		ThreatLists: []sb.ThreatDescriptor{
			sb.ThreatDescriptor{
				ThreatType:   sb.ThreatType_Malware,
				PlatformType: sb.PlatformType_AllPlatforms,
			},
		},
	}
client, err := sb.NewSafeBrowser(*conf)
...
threats, err := client.LookupURLs([]string{url})
...

When running tests I get this error

safebrowsing: 2017/01/04 14:53:06 database.go:186: ListUpdate failure: safebrowsing: unexpected server response code: 404
safebrowsing: 2017/01/04 14:53:06 safebrowser.go:365: inconsistent database: safebrowsing: unexpected server response code: 404

And looking at the source it seems that it will try to ListUpdate() every request.
What is the right way of running the lookup like documented here?

Thank You

@dsnet
Copy link
Contributor

dsnet commented Jan 4, 2017

I just tried running this on my machine and with the url set to something like "http://google.com" it printed the following:

safebrowsing: 2017/01/04 09:37:36 database.go:100: no database file specified
safebrowsing: 2017/01/04 09:37:38 database.go:291: database is now healthy
Results: [[]]

I'm surprised that you get 404 errors since nothing in your Config struct changed the ServerURL field.
What revision are you running on? Do you have any local changes?

@inge4pres
Copy link
Author

Hi @dsnet thanks for your support.
I grabbed the code with go get github.com/google/safebrowsing and did no changes to the source code.
Tried again now with the same config and got

=== RUN   TestCheckMaliciousURL
safebrowsing: 2017/01/07 12:26:40 database.go:100: no database file specified
safebrowsing: 2017/01/07 12:26:40 database.go:186: ListUpdate failure: safebrowsing: unexpected server response code: 404
safebrowsing: 2017/01/07 12:26:40 safebrowser.go:365: inconsistent database: safebrowsing: unexpected server response code: 404
--- FAIL: TestCheckMaliciousURL (0.14s)
	post_test.go:26: safebrowsing: unexpected server response code: 404

with a valid URL with trailing slash.
I am on Windows, maybe this is the issue? :)

@inge4pres
Copy link
Author

I resolved it by removing the ThreatList from the config, don't know why exactly.

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