-
Notifications
You must be signed in to change notification settings - Fork 171
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
fix: restrict secretFile
path
#669
Closed
MichaelDeSteven
wants to merge
58
commits into
mosn:main
from
MichaelDeSteven:fix_secret_file_restriction
Closed
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
1e7aa37
fix: configuration API returns wrong app_id
MichaelDeSteven 5797639
Merge branch 'main' into main
seeflood 66a2287
Merge branch 'mosn:main' into main
MichaelDeSteven d6b0518
fix: configuration API returns wrong store_name
MichaelDeSteven d94e9ce
Merge branch 'main' into main
seeflood 5c332da
Merge branch 'main' into main
seeflood 0b4d4a7
Merge branch 'main' into main
seeflood 463d37d
Update etcdv3.go
MichaelDeSteven 2e53758
Update etcdv3_test.go
MichaelDeSteven 533e32d
Update types.go
MichaelDeSteven 96fa1fc
Update api_configuration.go
MichaelDeSteven 3154441
Update types.go
MichaelDeSteven c46a944
Update etcdv3.go
MichaelDeSteven 05f846c
Merge branch 'main' into main
Xunzhuo a35bc0b
fix: configuration API returns wrong app_id
MichaelDeSteven 307bc23
Merge branch 'main' of https://github.com/MichaelDeSteven/layotto int…
MichaelDeSteven 71f0837
fix: apollo configuration API returns wrong store_name
MichaelDeSteven 23eadde
delete unused const
MichaelDeSteven 6c6ba21
delete: redundant assign line
MichaelDeSteven 88baba2
fix: unit test of etcdv3 subscribe
MichaelDeSteven df3d73f
delete: subscribereq redundant storename field
MichaelDeSteven 00bd590
Merge branch 'main' into main
MichaelDeSteven 1c82c02
Merge branch 'main' into main
wenxuwan adeac11
Merge branch 'mosn:main' into main
MichaelDeSteven 8e1f908
refactor: replace current apollo sdk with the official one
MichaelDeSteven f0a7b96
refactor: replace current apollo sdk with the official one
MichaelDeSteven 44b544e
refactor: replace current apollo sdk with the official one
MichaelDeSteven a77ceda
Merge branch 'main' into main
MichaelDeSteven 5b38153
refactor: replace current apollo sdk with the official one
MichaelDeSteven 610e407
update: go 1.17 module
MichaelDeSteven 951ee9a
refactor: replace current apollo sdk with the official one
MichaelDeSteven d71cc65
refactor: replace current apollo sdk with the official one
MichaelDeSteven f738737
refactor: replace current apollo sdk with the official one
MichaelDeSteven 015440b
Merge branch 'mosn:main' into main
MichaelDeSteven c700d99
fix: restrict secretFile path
MichaelDeSteven c49ea61
Merge branch 'main' into fix_secret_file_restriction
MichaelDeSteven a908f15
test: add GetPrefixConfigFilePath unit test
MichaelDeSteven 23f4b8c
Merge branch 'fix_secret_file_restriction' of https://github.com/Mich…
MichaelDeSteven 1894405
Merge branch 'main' into fix_secret_file_restriction
MichaelDeSteven 0b4f988
test: add GetPrefixConfigFilePath unit test
MichaelDeSteven c55d3fa
Merge branch 'main' into fix_secret_file_restriction
seeflood 79e4284
Merge branch 'main' into fix_secret_file_restriction
seeflood 2630016
change: rename config_secret_local_file.json to secret_local_file.json
MichaelDeSteven 25eef9e
Merge branch 'fix_secret_file_restriction' of https://github.com/Mich…
MichaelDeSteven cecdc31
add: secret wrapper component
MichaelDeSteven 79ce642
add: secret wrapper component
MichaelDeSteven da8a794
add: secret wrapper component
MichaelDeSteven adbadbd
delete: unused field
MichaelDeSteven 965ff5b
Merge branch 'main' into fix_secret_file_restriction
Xunzhuo c31d897
wrap component
seeflood ec4afdb
Merge pull request #2 from seeflood/wrap_component
MichaelDeSteven 8b41d2a
delete: unused component
MichaelDeSteven 26d5d4b
fix: startup parameter and path separator
MichaelDeSteven 70deeb7
fix: startup parameter
MichaelDeSteven f9e7247
Merge branch 'main' into fix_secret_file_restriction
seeflood 033ea40
start without `-c`
seeflood 02de6e8
Merge pull request #3 from seeflood/test_when_no_config
MichaelDeSteven e8e1103
Merge branch 'main' into fix_secret_file_restriction
MichaelDeSteven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2021 Layotto Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package secret | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/dapr/components-contrib/secretstores" | ||
) | ||
|
||
type wrapper struct { | ||
prefix string | ||
comp secretstores.SecretStore | ||
} | ||
|
||
func (w *wrapper) Init(metadata secretstores.Metadata) error { | ||
if metadata.Properties != nil { | ||
metadata.Properties["secretsFile"] = w.prefix + metadata.Properties["secretsFile"] | ||
} | ||
return w.comp.Init(metadata) | ||
} | ||
|
||
func (w *wrapper) GetSecret(req secretstores.GetSecretRequest) (secretstores.GetSecretResponse, error) { | ||
return w.comp.GetSecret(req) | ||
} | ||
|
||
func (w *wrapper) BulkGetSecret(req secretstores.BulkGetSecretRequest) (secretstores.BulkGetSecretResponse, error) { | ||
return w.comp.BulkGetSecret(req) | ||
} | ||
|
||
func Wrap(component secretstores.SecretStore) secretstores.SecretStore { | ||
return &wrapper{ | ||
comp: component, | ||
prefix: getPrefixConfigFilePath(), | ||
} | ||
} | ||
|
||
func getPrefixConfigFilePath() string { | ||
prefix := "" | ||
for i, str := range os.Args { | ||
if str == "-c" || str == "-config" { | ||
strs := strings.Split(os.Args[i+1], string(os.PathSeparator)) | ||
for _, s := range strs[:len(strs)-1] { | ||
prefix = prefix + s + string(os.PathSeparator) | ||
} | ||
break | ||
} | ||
} | ||
return prefix | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
FIXME
said that we should get the startup parameters in main.go and you can takelayotto/cmd/layotto/main.go
Line 455 in 9a31451
Checking
-c
or-config
here is not enough, since users can just./layotto start
and layotto will use the default configuration pathThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there means I can get configuration path by used
c.String("config")
in main.go to replaceif str == "-c" || str == "-config"
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! you can get the path by
c.String("config")
in main.go and then put it in a common place in the memoryWe need to review the code and find a suitable place to store the path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to store var in memory? Can you give me some refs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest way is to store it in the main.go as a global variable. But this "global variable" way is not "elegant".
I suggest you read the startup code and try to pass the var to the runtime server without using global variable.
If you really can't find a way, then use global variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelDeSteven Hi ,are u still working on it?
Do you need help? I can help with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry that I cant find the method of store var in startup code. can you give me some tips?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. let me take a look