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

611 replace ioutil usage #663

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 32 additions & 63 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@
"filename": "README.md",
"hashed_secret": "112bb791304791ddcf692e29fd5cf149b35fea37",
"is_verified": false,
"line_number": 37,
"is_secret": false
"line_number": 37
}
],
"core/app_shared.go": [
Expand All @@ -134,8 +133,7 @@
"filename": "core/app_shared.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 41,
"is_secret": false
"line_number": 41
}
],
"core/auth/apis.go": [
Expand All @@ -144,8 +142,7 @@
"filename": "core/auth/apis.go",
"hashed_secret": "394e3412459f79523e12e1fa95a4cf141ccff122",
"is_verified": false,
"line_number": 2095,
"is_secret": false
"line_number": 2095
}
],
"core/auth/auth.go": [
Expand All @@ -154,32 +151,28 @@
"filename": "core/auth/auth.go",
"hashed_secret": "417355fe2b66baa6826739a6d8006ab2ddcf5186",
"is_verified": false,
"line_number": 151,
"is_secret": false
"line_number": 151
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth.go",
"hashed_secret": "700f93e97a8aaf0664601a8f298ac5ad0ff13c37",
"is_verified": false,
"line_number": 153,
"is_secret": false
"line_number": 153
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth.go",
"hashed_secret": "58f3388441fbce0e48aef2bf74413a6f43f6dc70",
"is_verified": false,
"line_number": 933,
"is_secret": false
"line_number": 933
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth.go",
"hashed_secret": "94a7f0195bbbd2260c4e4d02b6348fbcd90b2b30",
"is_verified": false,
"line_number": 2440,
"is_secret": false
"line_number": 2440
}
],
"core/auth/auth_type_email.go": [
Expand All @@ -188,56 +181,49 @@
"filename": "core/auth/auth_type_email.go",
"hashed_secret": "f3f2fb17a3bf9f307cb6e79b61b9d4baf07dd681",
"is_verified": false,
"line_number": 75,
"is_secret": false
"line_number": 75
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_email.go",
"hashed_secret": "fe70d8c51780596c0b3399573122bba943a461da",
"is_verified": false,
"line_number": 76,
"is_secret": false
"line_number": 76
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_email.go",
"hashed_secret": "06354d205ab5a3b6c7ad2333c58f1ddc810c97ba",
"is_verified": false,
"line_number": 87,
"is_secret": false
"line_number": 87
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_email.go",
"hashed_secret": "7cbe6dcf7274355d223e3174e4d8a7ffb55a9227",
"is_verified": false,
"line_number": 156,
"is_secret": false
"line_number": 156
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_email.go",
"hashed_secret": "69411040443be576ce64fc793269d7c26dd0866a",
"is_verified": false,
"line_number": 253,
"is_secret": false
"line_number": 253
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_email.go",
"hashed_secret": "cba104f0870345d3ec99d55c06441bdce9fcf584",
"is_verified": false,
"line_number": 390,
"is_secret": false
"line_number": 390
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_email.go",
"hashed_secret": "c74f3640d83fd19d941a4f44b28fbd9e57f59eef",
"is_verified": false,
"line_number": 391,
"is_secret": false
"line_number": 391
}
],
"core/auth/auth_type_oidc.go": [
Expand All @@ -246,8 +232,7 @@
"filename": "core/auth/auth_type_oidc.go",
"hashed_secret": "0ade4f3edccc8888bef404fe6b3c92c13cdfad6b",
"is_verified": false,
"line_number": 376,
"is_secret": false
"line_number": 376
}
],
"core/auth/auth_type_username.go": [
Expand All @@ -256,48 +241,42 @@
"filename": "core/auth/auth_type_username.go",
"hashed_secret": "86f4f81d8dcd41f5f695464a3bba658467957bb3",
"is_verified": false,
"line_number": 64,
"is_secret": false
"line_number": 64
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_username.go",
"hashed_secret": "d6f3638bf6ffed24773951f1a48460efa6766362",
"is_verified": false,
"line_number": 65,
"is_secret": false
"line_number": 65
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_username.go",
"hashed_secret": "06354d205ab5a3b6c7ad2333c58f1ddc810c97ba",
"is_verified": false,
"line_number": 77,
"is_secret": false
"line_number": 77
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_username.go",
"hashed_secret": "7cbe6dcf7274355d223e3174e4d8a7ffb55a9227",
"is_verified": false,
"line_number": 179,
"is_secret": false
"line_number": 179
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_username.go",
"hashed_secret": "cba104f0870345d3ec99d55c06441bdce9fcf584",
"is_verified": false,
"line_number": 215,
"is_secret": false
"line_number": 215
},
{
"type": "Secret Keyword",
"filename": "core/auth/auth_type_username.go",
"hashed_secret": "c74f3640d83fd19d941a4f44b28fbd9e57f59eef",
"is_verified": false,
"line_number": 216,
"is_secret": false
"line_number": 216
}
],
"core/auth/service_static_token.go": [
Expand All @@ -306,8 +285,7 @@
"filename": "core/auth/service_static_token.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 78,
"is_secret": false
"line_number": 78
}
],
"driven/emailer/adapter.go": [
Expand All @@ -316,8 +294,7 @@
"filename": "driven/emailer/adapter.go",
"hashed_secret": "9df4524d2441f00999342c4541a39932198d4bb4",
"is_verified": false,
"line_number": 70,
"is_secret": false
"line_number": 70
}
],
"driven/profilebb/adapter.go": [
Expand All @@ -326,8 +303,7 @@
"filename": "driven/profilebb/adapter.go",
"hashed_secret": "36c48d6ac9d10902792fa78b9c2d7d535971c2cc",
"is_verified": false,
"line_number": 224,
"is_secret": false
"line_number": 221
}
],
"driven/storage/database.go": [
Expand All @@ -336,8 +312,7 @@
"filename": "driven/storage/database.go",
"hashed_secret": "6547f385c6d867e20f8217018a4d468a7d67d638",
"is_verified": false,
"line_number": 209,
"is_secret": false
"line_number": 209
}
],
"driver/web/apis_system.go": [
Expand All @@ -346,8 +321,7 @@
"filename": "driver/web/apis_system.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 700,
"is_secret": false
"line_number": 651
}
],
"driver/web/docs/gen/def.yaml": [
Expand All @@ -356,8 +330,7 @@
"filename": "driver/web/docs/gen/def.yaml",
"hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d",
"is_verified": false,
"line_number": 55,
"is_secret": false
"line_number": 55
}
],
"driver/web/docs/gen/gen_types.go": [
Expand All @@ -366,8 +339,7 @@
"filename": "driver/web/docs/gen/gen_types.go",
"hashed_secret": "c9739eab2dfa093cc0e450bf0ea81a43ae67b581",
"is_verified": false,
"line_number": 1673,
"is_secret": false
"line_number": 1673
}
],
"driver/web/docs/resources/admin/auth/login.yaml": [
Expand All @@ -376,8 +348,7 @@
"filename": "driver/web/docs/resources/admin/auth/login.yaml",
"hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d",
"is_verified": false,
"line_number": 26,
"is_secret": false
"line_number": 26
}
],
"driver/web/docs/resources/services/auth/account/auth-type/link.yaml": [
Expand All @@ -386,8 +357,7 @@
"filename": "driver/web/docs/resources/services/auth/account/auth-type/link.yaml",
"hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d",
"is_verified": false,
"line_number": 26,
"is_secret": false
"line_number": 26
}
],
"driver/web/docs/resources/services/auth/login.yaml": [
Expand All @@ -396,10 +366,9 @@
"filename": "driver/web/docs/resources/services/auth/login.yaml",
"hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d",
"is_verified": false,
"line_number": 24,
"is_secret": false
"line_number": 24
}
]
},
"generated_at": "2023-05-02T15:15:38Z"
"generated_at": "2023-06-01T20:57:30Z"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## Added
- Replace ioutil.ReadAll usage [#611] (https://github.com/rokwire/core-building-block/issues/611)

## [1.33.0] - 2023-05-02
- Username and password authentication [#658](https://github.com/rokwire/core-building-block/issues/658)

Expand Down
8 changes: 4 additions & 4 deletions core/auth/auth_type_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -401,7 +401,7 @@ func (a *oidcAuthImpl) loadOidcTokenWithParams(params map[string]string, oidcCon
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err)
}
Expand All @@ -410,7 +410,7 @@ func (a *oidcAuthImpl) loadOidcTokenWithParams(params map[string]string, oidcCon
}

var authToken oidcToken
err = json.Unmarshal(body, &authToken)
err = json.NewDecoder(resp.Body).Decode(&authToken)
if err != nil {
return nil, errors.WrapErrorAction(logutils.ActionUnmarshal, logutils.TypeToken, nil, err)
}
Expand Down Expand Up @@ -447,7 +447,7 @@ func (a *oidcAuthImpl) loadOidcUserInfo(token *oidcToken, url string) ([]byte, e
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeResponse, nil, err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/auth/auth_type_phone.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"core-building-block/utils"
"encoding/base64"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/url"
"regexp"
Expand Down Expand Up @@ -275,7 +275,7 @@ func makeRequest(ctx context.Context, method string, pathPart string, data url.V
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err)
}
Expand Down
9 changes: 3 additions & 6 deletions driven/identitybb/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package identitybb
import (
"core-building-block/core/model"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/url"

Expand Down Expand Up @@ -63,19 +63,16 @@ func (a *Adapter) GetUserProfile(baseURL string, externalUser model.ExternalSyst
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeResponse, nil, err)
}
if resp.StatusCode != 200 {
return nil, errors.ErrorData(logutils.StatusInvalid, logutils.TypeResponse, &logutils.FieldArgs{"status_code": resp.StatusCode, "error": string(body)})
}
if len(body) == 0 {
return nil, errors.ErrorData(logutils.StatusMissing, logutils.TypeResponseBody, nil)
}

var profileData map[string]interface{}
err = json.Unmarshal(body, &profileData)
err = json.NewDecoder(resp.Body).Decode(&profileData)
if err != nil {
return nil, errors.WrapErrorAction(logutils.ActionUnmarshal, logutils.TypeResponseBody, nil, err)
}
Expand Down
Loading