From cd2b1964c48670e1b227ae59960fdeea17703c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Wed, 17 Jan 2024 13:45:46 +0800 Subject: [PATCH] chore: add typos check linter in github actions (#285) * refactor: Disable JSON handling in logger/logger.go. * chore: Standardize spelling and add typos check workflows. - Update GitHub Action name to 'unit tests' - Add spell-check step with custom config to lint workflow - Use latest version of golangci/lint-action in lint workflow - Rename variable 'crypted' to 'encrypted' in crypto_windows.go - Fix typos in comments and error/log messages throughout the codebase - Update .gitignore to exclude typos.toml file --- .github/workflows/lint.yml | 6 ++++++ .github/workflows/unittest.yml | 2 +- .gitignore | 5 ++++- browsingdata/localstorage/localstorage.go | 2 +- browsingdata/sessionstorage/sessionstorage.go | 2 +- crypto/crypto_windows.go | 4 ++-- logger/logger.go | 2 +- typos.toml | 7 +++++++ 8 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 typos.toml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f9e0a0a..2a9893d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,6 +16,12 @@ jobs: go-version: "1.21.x" - name: Checkout code uses: actions/checkout@v3 + + - name: Check spelling with custom config file + uses: crate-ci/typos@master + with: + config: ./typos.toml + - name: Lint uses: golangci/golangci-lint-action@v3 with: diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 4c603f3..b90d3cc 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -5,7 +5,7 @@ on: - main workflow_dispatch: -name: run tests +name: unit tests jobs: test: strategy: diff --git a/.gitignore b/.gitignore index f2148f6..496dde1 100644 --- a/.gitignore +++ b/.gitignore @@ -201,4 +201,7 @@ hack-browser-data !/.github/*.md # Community -!CONTRIBUTING.md \ No newline at end of file +!CONTRIBUTING.md + +# CICD Config +!typos.toml \ No newline at end of file diff --git a/browsingdata/localstorage/localstorage.go b/browsingdata/localstorage/localstorage.go index 2652ebc..fdf7394 100644 --- a/browsingdata/localstorage/localstorage.go +++ b/browsingdata/localstorage/localstorage.go @@ -46,7 +46,7 @@ func (c *ChromiumLocalStorage) Parse(_ []byte) error { if len(value) < maxLocalStorageValueLength { s.fillValue(value) } else { - s.Value = fmt.Sprintf("value is too long, length is %d, supportted max length is %d", len(value), maxLocalStorageValueLength) + s.Value = fmt.Sprintf("value is too long, length is %d, supported max length is %d", len(value), maxLocalStorageValueLength) } if s.IsMeta { s.Value = fmt.Sprintf("meta data, value bytes is %v", value) diff --git a/browsingdata/sessionstorage/sessionstorage.go b/browsingdata/sessionstorage/sessionstorage.go index ad694e2..106ba3d 100644 --- a/browsingdata/sessionstorage/sessionstorage.go +++ b/browsingdata/sessionstorage/sessionstorage.go @@ -46,7 +46,7 @@ func (c *ChromiumSessionStorage) Parse(_ []byte) error { if len(value) < maxLocalStorageValueLength { s.fillValue(value) } else { - s.Value = fmt.Sprintf("value is too long, length is %d, supportted max length is %d", len(value), maxLocalStorageValueLength) + s.Value = fmt.Sprintf("value is too long, length is %d, supported max length is %d", len(value), maxLocalStorageValueLength) } if s.IsMeta { s.Value = fmt.Sprintf("meta data, value bytes is %v", value) diff --git a/crypto/crypto_windows.go b/crypto/crypto_windows.go index c5e1b58..3321898 100644 --- a/crypto/crypto_windows.go +++ b/crypto/crypto_windows.go @@ -30,7 +30,7 @@ func DecryptPassForYandex(key, encryptPass []byte) ([]byte, error) { } // chromium > 80 https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_win.cc -func aesGCMDecrypt(crypted, key, nounce []byte) ([]byte, error) { +func aesGCMDecrypt(encrypted, key, nounce []byte) ([]byte, error) { block, err := aes.NewCipher(key) if err != nil { return nil, err @@ -39,7 +39,7 @@ func aesGCMDecrypt(crypted, key, nounce []byte) ([]byte, error) { if err != nil { return nil, err } - origData, err := blockMode.Open(nil, nounce, crypted, nil) + origData, err := blockMode.Open(nil, nounce, encrypted, nil) if err != nil { return nil, err } diff --git a/logger/logger.go b/logger/logger.go index c403272..0ef09b5 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -11,7 +11,7 @@ import ( var Default = &Logger{ AddSource: true, IsVerbose: false, - IsJSONHandler: true, + IsJSONHandler: false, Level: slog.LevelWarn, ReplaceAttr: defaultReplaceAttrFunc, Output: os.Stderr, diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..65fa5e3 --- /dev/null +++ b/typos.toml @@ -0,0 +1,7 @@ +# See https://github.com/crate-ci/typos/blob/master/docs/reference.md to configure typos +[default.extend-words] +Readed = "Readed" +Sie = "Sie" +OT = "OT" +[files] +extend-exclude = ["go.mod", "go.sum"] \ No newline at end of file