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

add AK/SK Certification for uploading snapshot to cloud #972

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

liuqinguestc
Copy link
Contributor

What this PR does / why we need it:
add AK/SK Certification for uploading snapshot to cloud
Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release note:

@codecov
Copy link

codecov bot commented Jul 23, 2019

Codecov Report

Merging #972 into master will increase coverage by 0.29%.
The diff coverage is 52.52%.

@@            Coverage Diff             @@
##           master     #972      +/-   ##
==========================================
+ Coverage   34.32%   34.61%   +0.29%     
==========================================
  Files          89       92       +3     
  Lines       16608    16858     +250     
==========================================
+ Hits         5700     5835     +135     
- Misses      10096    10197     +101     
- Partials      812      826      +14
Impacted Files Coverage Δ
contrib/backup/multicloud/client.go 0% <0%> (ø) ⬆️
contrib/drivers/lvm/lvm.go 23.66% <0%> (-0.34%) ⬇️
...icloud/credentials/keystonecredentials/provider.go 65.9% <65.9%> (ø)
...ontrib/backup/multicloud/credentials/credential.go 69.23% <69.23%> (ø)
contrib/backup/multicloud/signer/signature.go 71.85% <71.85%> (ø)

@skdwriting
Copy link
Collaborator

Can you please attach the test report for this PR?

@wisererik
Copy link
Collaborator

@liuqinguestc I don't think your solution is correct when considering the identification when hotpot uploads snapshot to cloud through multi-cloud. IMO, signature should be generated in hotpot which will be passed to multi-cloud and identified in multi-cloud.

@liuqinguestc
Copy link
Contributor Author

@wisererik I just do as you said , I will delete some codes that do not need.

@xing-yang xing-yang added the feature there is a huge framework change or feature addition label Jul 27, 2019
@xing-yang
Copy link
Collaborator

Please add a release note.

@@ -0,0 +1,189 @@
// Copyright 2019 The OpenSDS Authors.
Copy link
Collaborator

@xxwjj xxwjj Jul 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client.go has the same feature code, please use that one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry,I can not use that, because the code is not same, and function is not the same.

@@ -0,0 +1,37 @@
// Copyright 2019 The OpenSDS Authors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileter is used for api-server client, please remove this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry,this is used for keystone.go, I can not remove this code.

@@ -101,3 +101,7 @@
go-tests = true
non-go = true
unused-packages = true

[[constraint]]
name = "github.com/emicklei/go-restful"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need go-restfull lib?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for getting signature. the code uses go-restful lib.

@@ -0,0 +1,61 @@
// Copyright 2019 The OpenSDS Authors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is used by auth.go

"strings"

"github.com/opensds/opensds/contrib/backup/multicloud/auth"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank line

@@ -56,4 +56,10 @@ const (
Read = "Read"
Write = "Write"
Execute = "Execute"

//Signature parameter name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these constants is only used for upload to snapshot to cloud, please move to contrib/backup/multi-cloud directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but as erik said. we should use public lib

@@ -66,8 +66,8 @@
version = "2.0.0"

[[constraint]]
branch = "master"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR is too huge for a single commit. 16K+ lines of code, please split it up.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -0,0 +1,37 @@
// Copyright 2019 The OpenSDS Authors.
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenSDS copyright missing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is these lines written newly by us?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenSDS copyright missing

Its there in the line 1

@@ -0,0 +1,189 @@
// Copyright 2019 The OpenSDS Authors.
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright


const (
ConfFile = "/etc/opensds/driver/multi-cloud.yaml"
DefaultUploadTimeout = 30 // in Seconds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add to conf


func (k *Keystone) loadConf(p string) (*MultiCloudConf, error) {
conf := &MultiCloudConf{
Endpoint: "http://127.0.0.1:8088",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

return nil, nil, err
}

requestDate := time.Now().UTC().Format("20060102")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the dates and times hard-coded ?

// and a termination string ("sign_request") in lowercase characters.
sign.credentialString,
//Step 4: Append the hash of the canonical request created in Task 1
hex.EncodeToString(makeSha256([]byte(sign.canonicalString))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it secure to store in String ? in JAVA it is recommended to store in char[], since due to GC not being done, the value of the String variable can be seen by a memory profiler

func (sign *Signature) buildSignature() {
// Step 1: Create the signing key, use the secret access key to create a series of
// hash-based message authentication codes (HMACs).
kSecret := sign.credValues.SecretAccessKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error handling ? in case any makeHMAC fails ?

// hash-based message authentication codes (HMACs).
kSecret := sign.credValues.SecretAccessKey
kDate := makeHmac([]byte("OPENSDS"+kSecret), []byte(sign.requestDate))
kRegion := makeHmac(kDate, []byte(sign.Region))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key and value not matching here, please check all

}

// stripExcessSpaces will trim multiple side-by-side spaces.
func stripExcessSpaces(vals []string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use strings.TrimSpace(s) ?

var canonicalURI string

if len(url.Opaque) > 0 {
canonicalURI = "/" + strings.Join(strings.Split(url.Opaque, "/")[3:], "/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

significance of [3:] ?

Copy link
Collaborator

@skdwriting skdwriting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 142 file changes for this?! Kindly update the points in the PR description as well.

@@ -66,8 +66,8 @@
version = "2.0.0"

[[constraint]]
branch = "master"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -0,0 +1,37 @@
// Copyright 2019 The OpenSDS Authors.
//
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is these lines written newly by us?

@@ -0,0 +1,37 @@
// Copyright 2019 The OpenSDS Authors.
//
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenSDS copyright missing

Its there in the line 1


func (k *Keystone) loadConf(p string) (*MultiCloudConf, error) {
conf := &MultiCloudConf{
Endpoint: "http://127.0.0.1:8088",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why hard-coded?

var r tokens.GetResult
// The service token may be expired or revoked, so retry to get new token.
err := utils.Retry(2, "verify token", false, func(retryIdx int, lastErr error) error {
if retryIdx > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you trying to do here. I see some confusion here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature there is a huge framework change or feature addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants