-
Notifications
You must be signed in to change notification settings - Fork 302
new plugin for Azure NetApp Pools & Pool volumes #6171
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: develop
Are you sure you want to change the base?
Changes from 6 commits
1b45b0e
02f2c89
b4d5226
50bd133
8e4473b
671af67
500287d
20b9db0
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 |
|---|---|---|
|
|
@@ -1149,6 +1149,52 @@ sub azure_list_sqlvms { | |
| return $full_response; | ||
| } | ||
|
|
||
| sub azure_list_resource_metrics_set_url { | ||
| my ($self, %options) = @_; | ||
|
|
||
| my $url = $self->{management_endpoint}; | ||
| $url .= "/" . $options{resource} . "/providers/microsoft.insights/metricDefinitions"; | ||
| $url .= (defined($options{force_api_version}) && $options{force_api_version} ne '') ? "?api-version=" . $options{force_api_version} : "?api-version=" . $self->{api_version}; | ||
| return $url; | ||
| } | ||
|
|
||
| sub azure_list_resource_metrics { | ||
| my ($self, %options) = @_; | ||
|
|
||
| my $full_response = []; | ||
| my $full_url = $self->azure_list_resource_metrics_set_url(%options); | ||
| while (1) { | ||
| my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => ''); | ||
| foreach (@{$response->{value}}) { | ||
| push @$full_response, $_; | ||
| } | ||
|
|
||
| last if (!defined($response->{nextLink})); | ||
| $full_url = $response->{nextLink}; | ||
| } | ||
|
|
||
| return $full_response; | ||
| } | ||
|
|
||
| sub azure_list_netapp_volumes_set_url { | ||
| my ($self, %options) = @_; | ||
|
|
||
| my $url = $self->{management_endpoint} . "/subscriptions/" . $self->{subscription} . "/resourcegroups/" . | ||
|
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. azure_list_netapp_volumes_set_url concatenates resource_group, account_name and pool_name directly into the URL path without encoding or validation; this may allow crafted input to manipulate the request URL. Details✨ AI Reasoning 🔧 How do I fix it? Reply |
||
| $options{resource_group} . "/providers/Microsoft.NetApp/netAppAccounts/" . $options{account_name} . | ||
| "/capacityPools/" . $options{pool_name} . "/volumes?api-version=" . $self->{api_version}; | ||
|
|
||
| return $url; | ||
| } | ||
|
|
||
| sub azure_list_netapp_volumes { | ||
| my ($self, %options) = @_; | ||
|
|
||
| my $full_url = $self->azure_list_netapp_volumes_set_url(%options); | ||
| my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => ''); | ||
|
|
||
| return $response->{value}; | ||
| } | ||
|
|
||
| sub azure_list_sqlelasticpools_set_url { | ||
| my ($self, %options) = @_; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -600,6 +600,44 @@ sub azure_get_publicip { | |||||
| return $self->execute(cmd_options => $cmd_options); | ||||||
| } | ||||||
|
|
||||||
| sub azure_list_resource_metrics_set_cmd { | ||||||
| my ($self, %options) = @_; | ||||||
|
|
||||||
| return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); | ||||||
|
|
||||||
| my $cmd_options = "monitor metrics list-definitions --resource '$options{resource}' --only-show-errors --output json"; | ||||||
|
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. azure_list_resource_metrics_set_cmd builds a shell command by concatenating --resource and other option values into cmd_options; this allows command injection. Use safe argument passing or proper escaping. Details✨ AI Reasoning 🔧 How do I fix it? Reply |
||||||
|
|
||||||
| return $cmd_options; | ||||||
| } | ||||||
|
|
||||||
| sub azure_list_resource_metrics { | ||||||
| my ($self, %options) = @_; | ||||||
|
|
||||||
| my $cmd_options = $self->azure_list_resource_metrics_set_cmd(%options); | ||||||
| my $raw_results = $self->execute(cmd_options => $cmd_options); | ||||||
|
|
||||||
| return $raw_results; | ||||||
| } | ||||||
|
|
||||||
| sub azure_list_netapp_volumes_set_cmd { | ||||||
| my ($self, %options) = @_; | ||||||
|
|
||||||
| return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); | ||||||
|
|
||||||
| my $cmd_options = "netappfiles volume list --account-name '$options{account_name}' --pool-name '$options{pool_name}' --resource-group '$options{resource_group}'"; | ||||||
|
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. azure_list_netapp_volumes_set_cmd builds a shell command by concatenating --account-name, --pool-name and --resource-group option values into cmd_options; this allows command injection. Use safe argument passing or proper escaping. Details✨ AI Reasoning 🔧 How do I fix it? Reply |
||||||
| $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); | ||||||
| return $cmd_options; | ||||||
| } | ||||||
|
|
||||||
| sub azure_list_netapp_volumes_metrics { | ||||||
|
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. Method name mismatch: azcli defines azure_list_netapp_volumes_metrics, but callers use azure_list_netapp_volumes. This causes runtime failure with --custommode=azcli.
Suggested change
Details✨ AI Reasoning Reply |
||||||
| my ($self, %options) = @_; | ||||||
|
|
||||||
| my $cmd_options = $self->azure_list_netapp_volumes_set_cmd(%options); | ||||||
| my $raw_results = $self->execute(cmd_options => $cmd_options); | ||||||
|
|
||||||
| return $raw_results; | ||||||
| } | ||||||
|
|
||||||
| 1; | ||||||
|
|
||||||
| __END__ | ||||||
|
|
||||||
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.
azure_list_resource_metrics_set_url concatenates $options{resource} directly into the request URL without encoding; untrusted resource values can manipulate the constructed HTTP path.
Details
✨ AI Reasoning
The management API URL is constructed by appending '/' . $options{resource} into the base management endpoint string. If $options{resource} is supplied externally, it may contain unexpected characters or sequences that change the resulting HTTP request (path traversal, injection into the URL). No encoding or validation is applied before concatenation.
🔧 How do I fix it?
Use parameterized queries with placeholders, array-based command execution (no shell interpretation), or properly escaped arguments using vetted libraries. Avoid dynamic queries/commands built with user input concatenation.
Reply
@AikidoSec feedback: [FEEDBACK]to get better review comments in the future.Reply
@AikidoSec ignore: [REASON]to ignore this issue.More info