-
Notifications
You must be signed in to change notification settings - Fork 3
Encapsulated key parameters in functions #3
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,9 +12,9 @@ codeunit 50101 BlobStorageManagement | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContainerContentText: Text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Authorization := StorageServiceAuthorization.CreateSharedKey(GetSharedKey()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContainerClient.Initialize('MY_STORAGE_ACCOUNT', Authorization); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContainerClient.Initialize(GetStorageAccount(), Authorization); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Create container | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Response := ContainerClient.CreateContainer('mycontainer'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Response := ContainerClient.CreateContainer(GetContainerName()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //List containers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Response := ContainerClient.ListContainers(Containers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if Response.IsSuccessful() then begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -27,7 +27,7 @@ codeunit 50101 BlobStorageManagement | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Message('Error: %1', Response.GetError()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Init Blob Client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BlobClient.Initialize('MY_STORAGE_ACCOUNT', 'mycontainer', Authorization); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BlobClient.Initialize(GetStorageAccount(), GetContainerName(), Authorization); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Create a blob (text content) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Response := BlobClient.PutBlobBlockBlobText('MyBlob', 'This is the content of my blob'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not Response.IsSuccessful() then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -48,7 +48,22 @@ codeunit 50101 BlobStorageManagement | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local procedure GetSharedKey(): SecretText | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [NonDebuggable] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| internal procedure GetSharedKey(): SecretText | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [NonDebuggable] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| internal procedure GetStorageAccount(): Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty key parameters break blob operationsHigh Severity
Additional Locations (2) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [NonDebuggable] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| internal procedure GetContainerName(): Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blank container name causes request failuresHigh Severity
Additional Locations (2) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
68
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end; | |
| [NonDebuggable] | |
| internal procedure GetStorageAccount(): Text | |
| begin | |
| end; | |
| [NonDebuggable] | |
| internal procedure GetContainerName(): Text | |
| begin | |
| Error('Storage shared key is not configured. Please implement GetSharedKey to return a valid shared key.'); | |
| end; | |
| [NonDebuggable] | |
| internal procedure GetStorageAccount(): Text | |
| begin | |
| Error('Storage account is not configured. Please implement GetStorageAccount to return a valid storage account name.'); | |
| end; | |
| [NonDebuggable] | |
| internal procedure GetContainerName(): Text | |
| begin | |
| Error('Container name is not configured. Please implement GetContainerName to return a valid container name.'); |


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.
GetSharedKey() now has internal visibility, which broadens access to the storage account key within the extension. Unless another object must call this, keeping it local reduces the risk of accidental secret exposure/misuse and better matches the goal of encapsulating key parameters.