Skip to content

Commit

Permalink
Merge pull request #4 from Seagate/feat/saswwn
Browse files Browse the repository at this point in the history
Feat/saswwn
  • Loading branch information
jskazinski authored Aug 5, 2022
2 parents c4f22d9 + e480970 commit 037c85c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
5 changes: 2 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ We take the security of the csi-lib-sas project seriously. If you find any secur

:warning: **Please do not publicly report any security vulnerabilities via GitHub issues.**

If you have concerns or questions, please email us at [[email protected]](mailto:[email protected]).
If you have concerns or questions, please email us at [[email protected]](mailto:[email protected]).

To report an actual vulnerability, please use the "[Seagate Responsible Vulnerability Disclosure Policy](https://www.seagate.com/legal-privacy/responsible-vulnerability-disclosure-policy/)"


### Reporting Format

To make your reporting meaningful and help us understand the nature and scope of the issue, please include as much information as possible.
To make your reporting meaningful and help us understand the nature and scope of the issue, please include as much information as possible.

### Preferred Languages

Expand Down
9 changes: 1 addition & 8 deletions SECURITY_CONTACTS
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@
# They are the contact point for the Product Security Team to reach out
# to for triaging and handling of incoming issues.
#
# The below names agree to abide by the
# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
# and will be removed and replaced if they violate that agreement.
#
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
# INSTRUCTIONS AT https://kubernetes.io/security/

jskazinski

[email protected]
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func main() {

// Use command line arguments for test settings
c := sas.Connector{
TargetWWN: *wwn,
VolumeWWN: *wwn,
}

dp, err := sas.Attach(ctx, &c, &sas.OSioHandler{})
Expand Down
28 changes: 14 additions & 14 deletions sas/sas.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ type ioHandler interface {

// Connector provides a struct to hold all of the needed parameters to make our SAS connection
type Connector struct {
VolumeName string `json:"volume_name"`
TargetWWN string `json:"target_wwn"`
Multipath bool `json:"multipath"`
TargetDevice string `json:"target_device"`
SCSIDevices []string `json:"scsi_devices"`
IoHandler ioHandler
VolumeName string `json:"volume_name"` // Passed In: A name given to the storage volume by the provisioner, for debugging.
VolumeWWN string `json:"volume_wwn"` // Passed In: 128 bit world wide name given to storage volume.
Multipath bool `json:"multipath"` // Discovered: True indicates that OSPathName is a multipath device (dm-#), otherwise it is a regular device (/dev/sdX)
OSPathName string `json:"os_device_path"` // Discovered: The OS path to the storage volume WWN, for example /dev/sdb or /dev/dm-5
OSDevicePaths []string `json:"scsi_devices"` // Discovered: The OS path(s) to the storage volume WWN, for example ["/dev/sdb"] or ["/dev/sdb", "/dev/sdc"]
IoHandler ioHandler // Passed In
}

// OSioHandler is a wrapper that includes all the necessary io functions used for (Should be used as default io handler)
Expand All @@ -68,7 +68,7 @@ func Attach(ctx context.Context, c *Connector, io ioHandler) (string, error) {
return "", err
}

return c.TargetDevice, nil
return c.OSPathName, nil
}

// Detach performs a detach operation on a volume
Expand Down Expand Up @@ -200,7 +200,7 @@ func discoverDevices(logger klog.Logger, c *Connector, io ioHandler) error {
var devices []string

c.Multipath = false
c.TargetDevice = ""
c.OSPathName = ""
rescaned := false

// two-phase search:
Expand All @@ -209,21 +209,21 @@ func discoverDevices(logger klog.Logger, c *Connector, io ioHandler) error {
for true {

// Find the multipath device using WWN
dm, devices = findDiskById(logger, c.TargetWWN, io)
dm, devices = findDiskById(logger, c.VolumeWWN, io)
logger.V(1).Info("find disk by id returned", "dm", dm, "devices", devices)

for _, device := range devices {
logger.V(3).Info("add scsi device", "device", device)
if device != "" {
c.SCSIDevices = append(c.SCSIDevices, device)
c.OSDevicePaths = append(c.OSDevicePaths, device)
}
}

// if multipath device is found, break
if dm != "" && len(c.SCSIDevices) > 0 {
if dm != "" && len(c.OSDevicePaths) > 0 {
c.Multipath = true
c.TargetDevice = dm
logger.V(1).Info("multipath device was discovered", "dm", dm, "SCSIDevices", c.SCSIDevices)
c.OSPathName = dm
logger.V(1).Info("multipath device was discovered", "dm", dm, "OSDevicePaths", c.OSDevicePaths)
break
}

Expand All @@ -239,7 +239,7 @@ func discoverDevices(logger klog.Logger, c *Connector, io ioHandler) error {
}

// if no disk matches input wwn, return error
c.TargetDevice = dm
c.OSPathName = dm
if dm == "" {
err := fmt.Errorf("no SAS disk found")
logger.Error(err, "no device discovered", "dm", dm)
Expand Down
2 changes: 1 addition & 1 deletion sas/sas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestSearchDisk(t *testing.T) {
logger, _ := ktesting.NewTestContext(t)
fakeConnector := Connector{
VolumeName: "fakeVol",
TargetWWN: "3600508b400105e210000900000490000",
VolumeWWN: "3600508b400105e210000900000490000",
}

error := discoverDevices(logger, &fakeConnector, &fakeIOHandler{})
Expand Down

0 comments on commit 037c85c

Please sign in to comment.