Skip to content

Commit d5e97de

Browse files
[refactor] backdates go-sqlite, fixes reference inconsistencies
1 parent 6465fe6 commit d5e97de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+545
-1528
lines changed

.github/workflows/ci.yml

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,80 @@
1-
name: CI
1+
name: Go
22

33
on: [push, pull_request]
44

55
jobs:
6-
build:
6+
test:
7+
name: Test
8+
runs-on: ${{ matrix.os }}
9+
defaults:
10+
run:
11+
shell: bash
712
strategy:
813
matrix:
9-
go-version: [1.13.x, 1.14.x, 1.15.x]
10-
platform: [ubuntu-latest]
11-
runs-on: ${{ matrix.platform }}
14+
os: [ubuntu-latest, macos-latest]
15+
go: ['1.22', '1.23']
16+
fail-fast: false
17+
env:
18+
OS: ${{ matrix.os }}
19+
GO: ${{ matrix.go }}
1220
steps:
13-
- name: Install Go
14-
uses: actions/setup-go@v2
15-
with:
16-
go-version: ${{ matrix.go-version }}
17-
- name: Checkout code
18-
uses: actions/checkout@v2
19-
- name: Test
20-
run: |
21-
go get github.com/frankbraun/gocheck
22-
export PATH=$GOPATH/bin:$PATH
23-
make test
21+
- uses: actions/setup-go@v5
22+
with:
23+
go-version: ${{ matrix.go }}
24+
- if: startsWith(matrix.os, 'macos')
25+
run: brew update
26+
- name: Get Build Tools
27+
run: |
28+
go install github.com/ory/go-acc@latest
29+
- name: Add $GOPATH/bin to $PATH
30+
run: |
31+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
32+
- uses: actions/checkout@v4
33+
- name: Test
34+
run: |
35+
go-acc . -- -race -v -tags "sqlite_allow_uri_authority sqlite_app_armor sqlite_column_metadata sqlite_foreign_keys sqlite_fts5 sqlite_introspect sqlite_json sqlite_math_functions sqlite_os_trace sqlite_preupdate_hook sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_unlock_notify sqlite_vacuum_incr sqlite_vtable"
36+
- name: Upload coverage to Codecov
37+
uses: codecov/codecov-action@v4
38+
with:
39+
env_vars: OS,GO
40+
file: coverage.txt
41+
42+
test-windows:
43+
name: Test for Windows
44+
runs-on: windows-latest
45+
defaults:
46+
run:
47+
shell: bash
48+
strategy:
49+
matrix:
50+
go: ['1.21', '1.22']
51+
fail-fast: false
52+
env:
53+
OS: windows-2019
54+
GO: ${{ matrix.go }}
55+
steps:
56+
- uses: msys2/setup-msys2@v2
57+
with:
58+
update: true
59+
install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-sqlcipher mingw-w64-x86_64-icu
60+
msystem: MINGW64
61+
path-type: inherit
62+
- uses: actions/setup-go@v5
63+
with:
64+
go-version: ${{ matrix.go }}
65+
- name: Get Build Tools
66+
run: |
67+
go install github.com/ory/go-acc@latest
68+
- name: Add $GOPATH/bin to $PATH
69+
run: |
70+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
71+
shell: msys2 {0}
72+
- uses: actions/checkout@v4
73+
- name: 'Test'
74+
run: go-acc . -- -race -v -tags "sqlite_allow_uri_authority sqlite_app_armor sqlite_column_metadata sqlite_foreign_keys sqlite_fts5 sqlite_introspect sqlite_json sqlite_math_functions sqlite_os_trace sqlite_preupdate_hook sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_unlock_notify sqlite_vacuum_incr sqlite_vtable"
75+
shell: msys2 {0}
76+
- name: Upload coverage to Codecov
77+
uses: codecov/codecov-action@v4
78+
with:
79+
env_vars: OS,GO
80+
file: coverage.txt

MAINTENANCE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ tracked for changes (maintenance details below):
99
Update code from https://github.com/mattn/go-sqlite3
1010
----------------------------------------------------
1111

12-
Current release: v1.14.5
12+
Current release: master
1313

1414
Use ./track_go-sqlite3.sh
1515

1616

1717
Update code from https://github.com/sqlcipher/sqlcipher
1818
-------------------------------------------------------
1919

20-
Current release: v4.4.2
20+
Current release: v4.6.1
2121

2222
Execute:
2323
./configure
@@ -31,7 +31,7 @@ sqlite3.c
3131
Update code from https://github.com/libtom/libtomcrypt
3232
------------------------------------------------------
3333

34-
Current HEAD: cfbd7f8d364e1438555ff2a247f7e17add11840e
34+
Current HEAD: develop
3535
(from develop branch, 2020-08-29)
3636

3737
Use ./track_libtomcrypt.sh

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
## go-sqlcipher
22

3-
[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/Boolean-Autocrat/go-sqlcipher)
3+
[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/mutecomm/go-sqlcipher) [![CI](https://github.com/mutecomm/go-sqlcipher/workflows/CI/badge.svg)](https://github.com/mutecomm/go-sqlcipher/actions)
44

55
### Description
66

77
Self-contained Go sqlite3 driver with an AES-256 encrypted sqlite3 database
88
conforming to the built-in database/sql interface. It is based on:
99

10-
- Go sqlite3 driver: https://github.com/mattn/go-sqlite3
11-
- SQLite extension with AES-256 codec: https://github.com/sqlcipher/sqlcipher
12-
- AES-256 implementation from: https://github.com/libtom/libtomcrypt
10+
- Go sqlite3 driver: https://github.com/mattn/go-sqlite3 (master)
11+
- SQLite extension with AES-256 codec: https://github.com/sqlcipher/sqlcipher (4.6.1)
12+
- AES-256 implementation from: https://github.com/libtom/libtomcrypt (develop)
1313

1414
SQLite itself is part of SQLCipher.
1515

@@ -25,6 +25,10 @@ to upgrade existing database files.
2525

2626
See [migrating databases](https://www.zetetic.net/sqlcipher/sqlcipher-api/#Migrating_Databases) for details.
2727

28+
To upgrade your Go code to the 4.x series, change the import path to
29+
30+
"github.com/Boolean-Autocrat/go-sqlcipher"
31+
2832
### Installation
2933

3034
This package can be installed with the go get command:
@@ -37,30 +41,30 @@ To create and open encrypted database files use the following DSN parameters:
3741

3842
```go
3943
key := "2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99"
40-
dbname := fmt.Sprintf("db?_pragma_key=x'%s'&_pragma_cipher_page_size=4096", key)
44+
dbname := fmt.Sprintf("db?_key=x'%s'&_pragma_cipher_page_size=4096", key)
4145
db, _ := sql.Open("sqlite3", dbname)
4246
```
4347

44-
`_pragma_key` is the hex encoded 32 byte key (must be 64 characters long).
48+
`_key` is the hex encoded 32 byte key (must be 64 characters long).
4549
`_pragma_cipher_page_size` is the page size of the encrypted database (set if
4650
you want a different value than the default size).
4751

4852
```go
4953
key := url.QueryEscape("secret")
50-
dbname := fmt.Sprintf("db?_pragma_key=%s&_pragma_cipher_page_size=4096", key)
54+
dbname := fmt.Sprintf("db?_key=%s&_pragma_cipher_page_size=4096", key)
5155
db, _ := sql.Open("sqlite3", dbname)
5256
```
5357

54-
This uses a passphrase directly as `_pragma_key` with the key derivation function in
58+
This uses a passphrase directly as `_key` with the key derivation function in
5559
SQLCipher. Do not forget the `url.QueryEscape()` call in your code!
5660

5761
See also [PRAGMA key](https://www.zetetic.net/sqlcipher/sqlcipher-api/#PRAGMA_key).
5862

5963
API documentation can be found here:
60-
http://godoc.org/github.com/Boolean-Autocrat/go-sqlcipher
64+
http://godoc.org/github.com/mutecomm/go-sqlcipher
6165

6266
Use the function
63-
[sqlite3.IsEncrypted()](https://godoc.org/github.com/Boolean-Autocrat/go-sqlcipher#IsEncrypted)
67+
[sqlite3.IsEncrypted()](https://godoc.org/github.com/mutecomm/go-sqlcipher#IsEncrypted)
6468
to check whether a database file is encrypted or not.
6569

6670
Examples can be found under the `./_example` directory

_example/custom_driver_name/Makefile

Lines changed: 0 additions & 12 deletions
This file was deleted.

_example/custom_driver_name/main.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

_example/custom_func/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"math"
88
"math/rand"
99

10-
sqlite "github.com/mattn/go-sqlite3"
10+
sqlite "github.com/Boolean-Autocrat/go-sqlcipher"
1111
)
1212

1313
// Computes x^y

_example/fuzz/fuzz_openexec.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

_example/hook/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"os"
77

8-
"github.com/mattn/go-sqlite3"
8+
sqlite3 "github.com/Boolean-Autocrat/go-sqlcipher"
99
)
1010

1111
func main() {

_example/json/json.go

Lines changed: 0 additions & 81 deletions
This file was deleted.

_example/limit/limit.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import (
77
"os"
88
"strings"
99

10-
"github.com/mattn/go-sqlite3"
10+
sqlite3 "github.com/Boolean-Autocrat/go-sqlcipher"
1111
)
1212

13-
func createBulkInsertQuery(n int, start int) (query string, args []any) {
13+
func createBulkInsertQuery(n int, start int) (query string, args []interface{}) {
1414
values := make([]string, n)
15-
args = make([]any, n*2)
15+
args = make([]interface{}, n*2)
1616
pos := 0
1717
for i := 0; i < n; i++ {
1818
values[i] = "(?, ?)"
1919
args[pos] = start + i
20-
args[pos+1] = fmt.Sprintf("こんにちは世界%03d", i)
20+
args[pos+1] = fmt.Sprintf("こんにちわ世界%03d", i)
2121
pos += 2
2222
}
2323
query = fmt.Sprintf(
@@ -27,7 +27,7 @@ func createBulkInsertQuery(n int, start int) (query string, args []any) {
2727
return
2828
}
2929

30-
func bulkInsert(db *sql.DB, query string, args []any) (err error) {
30+
func bulkInsert(db *sql.DB, query string, args []interface{}) (err error) {
3131
stmt, err := db.Prepare(query)
3232
if err != nil {
3333
return

0 commit comments

Comments
 (0)