Skip to content

Commit aeb0b24

Browse files
authored
Merge pull request #257 from IBM-Cloud/dev
Promote dev to master
2 parents 9b63e2d + ccf0da0 commit aeb0b24

19 files changed

+987
-128
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This is an example configuration to enable detect-secrets in the pre-commit hook.
2+
# Add this file to the root folder of your repository.
3+
#
4+
# Read pre-commit hook framework https://pre-commit.com/ for more details about the structure of config yaml file and how git pre-commit would invoke each hook.
5+
#
6+
# This line indicates we will use the hook from ibm/detect-secrets to run scan during committing phase.
7+
# Whitewater/whitewater-detect-secrets would sync code to ibm/detect-secrets upon merge.
8+
- repo: https://github.com/ibm/detect-secrets
9+
# If you desire to use a specific version of detect-secrets, you can replace `master` with other git revisions such as branch, tag or commit sha.
10+
# You are encouraged to use static refs such as tags, instead of branch name
11+
#
12+
# Running "pre-commit autoupdate" would automatically updates rev to latest tag
13+
rev: master
14+
hooks:
15+
- id: detect-secrets # pragma: whitelist secret
16+
# Add options for detect-secrets-hook binary. You can run `detect-secrets-hook --help` to list out all possible options.
17+
# You may also run `pre-commit run detect-secrets` to preview the scan result.
18+
# when "--baseline" without "--use-all-plugins", pre-commit scan with just plugins in baseline file
19+
# when "--baseline" with "--use-all-plugins", pre-commit scan with all available plugins
20+
# add "--fail-on-non-audited" to fail pre-commit for unaudited potential secrets
21+
args: [--baseline, .secrets.baseline, --use-all-plugins, --fail-on-non-audited]

.secrets.baseline

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2021-04-16T18:38:00Z",
6+
"generated_at": "2021-09-15T17:17:42Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
1010
},
1111
{
1212
"name": "ArtifactoryDetector"
1313
},
14+
{
15+
"name": "AzureStorageKeyDetector"
16+
},
1417
{
1518
"base64_limit": 4.5,
1619
"name": "Base64HighEntropyString"
@@ -25,6 +28,7 @@
2528
"name": "CloudantDetector"
2629
},
2730
{
31+
"ghe_instance": "github.ibm.com",
2832
"name": "GheDetector"
2933
},
3034
{
@@ -47,6 +51,9 @@
4751
{
4852
"name": "MailchimpDetector"
4953
},
54+
{
55+
"name": "NpmDetector"
56+
},
5057
{
5158
"name": "PrivateKeyDetector"
5259
},
@@ -56,6 +63,9 @@
5663
{
5764
"name": "SoftlayerDetector"
5865
},
66+
{
67+
"name": "SquareOAuthDetector"
68+
},
5969
{
6070
"name": "StripeDetector"
6171
},
@@ -77,59 +87,77 @@
7787
"hashed_secret": "c2df5d3d760ff42f33fb38e2534d4c1b7ddde3ab",
7888
"is_secret": false,
7989
"is_verified": false,
80-
"line_number": 26,
90+
"line_number": 29,
8191
"type": "Secret Keyword",
8292
"verified_result": null
8393
},
8494
{
8595
"hashed_secret": "c287d1da815abde11f19d14ab6f9dba01f57698e",
8696
"is_secret": false,
8797
"is_verified": false,
88-
"line_number": 27,
98+
"line_number": 30,
8999
"type": "Secret Keyword",
90100
"verified_result": null
91101
},
92102
{
93103
"hashed_secret": "41aaaaa69550b140807e70dcc170a497dbeadf0d",
94104
"is_secret": false,
95105
"is_verified": false,
96-
"line_number": 30,
106+
"line_number": 33,
97107
"type": "Secret Keyword",
98108
"verified_result": null
99109
},
100110
{
101111
"hashed_secret": "ca51a3e5092ede254e7121c4fc9fb07a0a55f2a0",
102112
"is_secret": false,
103113
"is_verified": false,
104-
"line_number": 31,
114+
"line_number": 34,
105115
"type": "Secret Keyword",
106116
"verified_result": null
107117
},
108118
{
109119
"hashed_secret": "d327b16674fb457f595a2bc5cdbd98f8143632be",
110120
"is_secret": false,
111121
"is_verified": false,
112-
"line_number": 32,
122+
"line_number": 35,
123+
"type": "Secret Keyword",
124+
"verified_result": null
125+
},
126+
{
127+
"hashed_secret": "3c81615afb40d1889fc2e1fff551a8b59b4e80ce",
128+
"is_secret": false,
129+
"is_verified": false,
130+
"line_number": 36,
113131
"type": "Secret Keyword",
114132
"verified_result": null
115133
},
116134
{
117135
"hashed_secret": "3438d9111af8058916e075b463bd7a6583cbf012",
118136
"is_secret": false,
119137
"is_verified": false,
120-
"line_number": 212,
138+
"line_number": 233,
121139
"type": "Secret Keyword",
122140
"verified_result": null
123141
},
124142
{
125143
"hashed_secret": "53213c46677ac6f5576c44a4cbbdbe186d67cb00",
126144
"is_secret": false,
127145
"is_verified": false,
128-
"line_number": 214,
146+
"line_number": 235,
129147
"type": "Secret Keyword",
130148
"verified_result": null
131149
}
132150
],
151+
"bluemix/authentication/iam/iam_test.go": [
152+
{
153+
"hashed_secret": "c8f0df25bade89c1873f5f01b85bcfb921443ac6",
154+
"is_secret": false,
155+
"is_verified": false,
156+
"line_number": 19,
157+
"type": "JSON Web Token",
158+
"verified_result": null
159+
}
160+
],
133161
"bluemix/authentication/uaa/uaa.go": [
134162
{
135163
"hashed_secret": "3438d9111af8058916e075b463bd7a6583cbf012",
@@ -140,6 +168,16 @@
140168
"verified_result": null
141169
}
142170
],
171+
"bluemix/configuration/core_config/bx_config_test.go": [
172+
{
173+
"hashed_secret": "9507a758af9127f99a700b500657fd558b705dc9",
174+
"is_secret": false,
175+
"is_verified": false,
176+
"line_number": 274,
177+
"type": "JSON Web Token",
178+
"verified_result": null
179+
}
180+
],
143181
"bluemix/configuration/core_config/cf_config.go": [
144182
{
145183
"hashed_secret": "e85f6eac7402c010fcea6b6d024a1875ac213f99",
@@ -167,19 +205,27 @@
167205
"type": "JSON Web Token",
168206
"verified_result": null
169207
},
208+
{
209+
"hashed_secret": "42be9b0e85dc9f0fcb42c69058b133fd23dfde2b",
210+
"is_secret": false,
211+
"is_verified": false,
212+
"line_number": 21,
213+
"type": "JSON Web Token",
214+
"verified_result": null
215+
},
170216
{
171217
"hashed_secret": "73f596843cdc77ecc6a0a4cdc5b5d89071ad1b79",
172218
"is_secret": false,
173219
"is_verified": false,
174-
"line_number": 19,
220+
"line_number": 25,
175221
"type": "JSON Web Token",
176222
"verified_result": null
177223
},
178224
{
179225
"hashed_secret": "63a47776714d85556701c61dd731a302ed132385",
180226
"is_secret": false,
181227
"is_verified": false,
182-
"line_number": 27,
228+
"line_number": 33,
183229
"type": "Hex High Entropy String",
184230
"verified_result": null
185231
}
@@ -537,7 +583,7 @@
537583
}
538584
]
539585
},
540-
"version": "0.13.1+ibm.34.dss",
586+
"version": "0.13.1+ibm.45.dss",
541587
"word_list": {
542588
"file": null,
543589
"hash": null

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contributing to Atom
1+
# Contributing to IBM Cloud CLI SDK
22

33
:+1:First of all, thanks for your time to contribute!:tada:
44

@@ -16,6 +16,9 @@ We follow the offical [CodeReviewComments](https://github.com/golang/go/wiki/Cod
1616

1717
Make sure you have good unit test. Run `go test -cover $(go list ./...)`, and ensure coverage is above 80% for major packages (aka packages other than i18n, fakes, docs...).
1818

19+
#### Secret Detection
20+
This project uses the IBM Detect Secrets Module. Install the module, by following these [instructions](https://github.com/ibm/detect-secrets#installupgrade-module). Once installed, enable the pre-commit secret detection hook by following these [instructions](https://github.com/ibm/detect-secrets#installupgrade-module) to ensure no secrets are committed to this repo.
21+
1922

2023
#### Commit Message
2124

bluemix/authentication/auth.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func (r *TokenRequest) ResponseTypes() []ResponseType {
3737
return r.responseTypes
3838
}
3939

40+
func (r *TokenRequest) GetTokenParam(key string) string {
41+
return r.params.Get(key)
42+
}
43+
4044
func (r *TokenRequest) SetResponseType(responseTypes ...ResponseType) {
4145
r.responseTypes = responseTypes
4246
}

bluemix/authentication/auth_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package authentication_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/authentication"
7+
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/authentication/iam"
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestGetTokenParam(t *testing.T) {
12+
req := authentication.NewTokenRequest(iam.GrantTypeCRToken)
13+
profileParam := "myProfile"
14+
req.SetTokenParam("profile", profileParam)
15+
16+
parsedParam := req.GetTokenParam("profile")
17+
18+
assert.Equal(t, profileParam, parsedParam)
19+
}

bluemix/authentication/iam/iam.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const (
1818
defaultClientSecret = "bx"
1919
defaultUAAClientID = "cf"
2020
defaultUAAClientSecret = ""
21+
crTokenParam = "cr_token"
22+
profileIDParam = "profile_id"
23+
profileNameParam = "profile_name"
2124
)
2225

2326
// Grant types
@@ -30,6 +33,7 @@ const (
3033
GrantTypeDelegatedRefreshToken authentication.GrantType = "urn:ibm:params:oauth:grant-type:delegated-refresh-token" // #nosec G101
3134
GrantTypeIdentityCookie authentication.GrantType = "urn:ibm:params:oauth:grant-type:identity-cookie"
3235
GrantTypeDerive authentication.GrantType = "urn:ibm:params:oauth:grant-type:derive"
36+
GrantTypeCRToken authentication.GrantType = "urn:ibm:params:oauth:grant-type:cr-token"
3337
)
3438

3539
// Response types
@@ -81,6 +85,23 @@ func APIKeyTokenRequest(apikey string, opts ...authentication.TokenOption) *auth
8185
return r
8286
}
8387

88+
func CRTokenRequest(crToken string, profileID string, profileName string, opts ...authentication.TokenOption) *authentication.TokenRequest {
89+
r := authentication.NewTokenRequest(GrantTypeCRToken)
90+
r.SetTokenParam(crTokenParam, crToken)
91+
92+
if profileID != "" {
93+
r.SetTokenParam(profileIDParam, profileID)
94+
}
95+
if profileName != "" {
96+
r.SetTokenParam(profileNameParam, profileName)
97+
}
98+
99+
for _, o := range opts {
100+
r.WithOption(o)
101+
}
102+
return r
103+
}
104+
84105
func RefreshTokenRequest(refreshToken string, opts ...authentication.TokenOption) *authentication.TokenRequest {
85106
r := authentication.NewTokenRequest(GrantTypeRefreshToken)
86107
r.SetTokenParam("refresh_token", refreshToken)

0 commit comments

Comments
 (0)