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

mysql type error Value type []uint8 into type *time.Time for various tables #234

Open
FalcoGer opened this issue Jan 20, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@FalcoGer
Copy link

What did you do? (required. The issue will be closed when not provided.)

I fetched exploitdb, then trying to fetch awesomepoc, yielded an error message.
Clearing the fetch_meta table allowed me to fetch the awesomepoc data without that error.

What did you expect to happen?

  • Fetching the data

What happened instead?

  • Abort with error.
  • Current Output

Please re-run the command using -debug and provide the output below.

$ go-exploitdb fetch inthewild --dbtype mysql --dbpath "goexploitdb:passwd@tcp(serverhostname:3306)" --debug --debug-sql

2025/01/20 10:02:43 /home/user/repositories/go-exploitdb/db/rdb.go:438
[2.554ms] [rows:-] SELECT DATABASE()
[...]
2025/01/20 10:02:45 /home/user/repositories/go-exploitdb/db/rdb.go:142
[10.217ms] [rows:1] SELECT SCHEMA_NAME from Information_schema.SCHEMATA where SCHEMA_NAME LIKE 'goexploitdb%' ORDER BY SCHEMA_NAME='goexploitdb' DESC,SCHEMA_NAME limit 1

2025/01/20 10:02:45 /home/user/repositories/go-exploitdb/db/rdb.go:142
[40.906ms] [rows:-] SELECT count(*) FROM information_schema.statistics WHERE table_schema = 'goexploitdb' AND table_name = 'in_the_wilds' AND index_name = 'idx_in_the_wild_exploit_id'

2025/01/20 10:02:45 /home/user/repositories/go-exploitdb/db/rdb.go:463 sql: Scan error on column index 1, name "created_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time
[8.572ms] [rows:1] SELECT * FROM `fetch_meta` WHERE `fetch_meta`.`deleted_at` IS NULL LIMIT 1
Failed to get FetchMeta from DB. err: sql: Scan error on column index 1, name "created_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time

Steps to reproduce the behaviour

  1. Connect to mysql and create new database and user
CREATE DATABASE goexploitdb;
CREATE USER 'goexploitdb'@'%' IDENTIFIED BY 'passwd';
GRANT ALL PRIVILEGES ON goexploitdb.* TO 'goexploitdb'@'%';
  1. Fetch any of the data using the fetch command. This will initially work.
  2. Run the exact same command again. It will fail now with the error message: Failed to get FetchMeta from DB. err: sql: Scan error on column index 1, name "created_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time

Configuration (MUST fill this out):

  • Go version (go version): go version go1.23.4 linux/amd64
  • Go environment (go env):
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go-1.23'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go-1.23/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3396132397=/tmp/go-build -gno-record-gcc-switches'
  • go-exploitdb environment: 7d2fc13a9f55fa36e545077c9dfb63c3db0d099c
  • go-exploitdb version: go-exploitdb v0.5.0 7d2fc13
  • command: See above
@FalcoGer FalcoGer added the bug Something isn't working label Jan 20, 2025
@FalcoGer
Copy link
Author

Same issue when actually searching

$ go-exploitdb search --param "CVE-2021-3156" --dbtype mysql --dbpath "goexploitdb:passwd@tcp(serverhostname:3306)" --debug

Failed to get OffensiveSecurity. err: sql: Scan error on column index 4, name "date_published": unsupported Scan, storing driver.Value type []uint8 into type *time.Time

@FalcoGer FalcoGer changed the title Fetching into mysql database causes error when fetch_meta table populated. mysql type error Value type []uint8 into type *time.Time for various tables Jan 20, 2025
@MaineK00n MaineK00n self-assigned this Feb 4, 2025
@MaineK00n
Copy link
Collaborator

@FalcoGer
Sorry for the late reply.
You need to add parseTime=True.

$ go-exploitdb fetch awesomepoc --dbtype mysql --dbpath "root:password@tcp(127.0.0.1:3306)/test"
INFO[02-04|09:59:27] Fetching Awesome Poc Exploit 
INFO[02-04|09:59:27] Awesome Poc Exploit                      count=823
INFO[02-04|09:59:27] Insert Exploit into go-exploitdb.        db=mysql
INFO[02-04|09:59:27] Inserting 823 Exploits 
INFO[02-04|09:59:27] Inserting new Exploits 
823 / 823 [-----------------------------------------------------------------------------------------] 100.00% 4108 p/s
INFO[02-04|09:59:27] No CveID Exploit Count                   count=0
INFO[02-04|09:59:27] CveID Exploit Count                      count=823

$ go-exploitdb fetch awesomepoc --dbtype mysql --dbpath "root:password@tcp(127.0.0.1:3306)/test"
Failed to get FetchMeta from DB. err: sql: Scan error on column index 1, name "created_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time

$ go-exploitdb fetch awesomepoc --dbtype mysql --dbpath "root:password@tcp(127.0.0.1:3306)/test?parseTime=true"
INFO[02-04|09:59:41] Fetching Awesome Poc Exploit 
INFO[02-04|09:59:41] Awesome Poc Exploit                      count=823
INFO[02-04|09:59:41] Insert Exploit into go-exploitdb.        db=mysql
INFO[02-04|09:59:41] Inserting 823 Exploits 
INFO[02-04|09:59:41] Deleting old Exploits 
823 / 823 [--------------------------------------------------------------------------------------------] 100.00% ? p/s
INFO[02-04|09:59:41] Inserting new Exploits 
823 / 823 [--------------------------------------------------------------------------------------------] 100.00% ? p/s
INFO[02-04|09:59:42] No CveID Exploit Count                   count=0
INFO[02-04|09:59:42] CveID Exploit Count                      count=823

@FalcoGer
Copy link
Author

FalcoGer commented Feb 4, 2025

that does it. but I don't know why.
maybe some kind of documentation, automatically doing that, or a nicer error message would be nice.

@MaineK00n
Copy link
Collaborator

The reason is as follows.

parseTime=true changes the output type of DATE and DATETIME values to time.Time instead of []byte / string The date or datetime like 0000-00-00 00:00:00 is converted into zero value of time.Time.

https://github.com/go-sql-driver/mysql?tab=readme-ov-file#parsetime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants