]> git.proxmox.com Git - pmg-api.git/commitdiff
api/quarantine: add safer endpoint for user white/blacklist address deletion
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 9 Mar 2020 11:18:16 +0000 (12:18 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 9 Mar 2020 17:22:10 +0000 (18:22 +0100)
having the entry as part of the url causes many problems since it can
contain special characters like '/.,' etc., and that can break API
call path-to-method resolution.

Passing it as parameter makes it easier for callers (frontends) and
safer for backend to use

Note that the new api calls overwrites the parameter pattern with '',
so no formatting limits for the entries

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
[ Thomas: improved commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/API2/Quarantine.pm

index 5cb0f8e6765a0360e27da66fd9395e5d6a6fa19d..272dfdb64f1e6dd3ea77247fb5e87ba3f020644b 100644 (file)
@@ -275,6 +275,33 @@ __PACKAGE__->register_method ({
        return undef;
     }});
 
+__PACKAGE__->register_method ({
+    name => 'whitelist_delete_base',
+    path => 'whitelist',
+    method => 'DELETE',
+    description => "Delete user whitelist entries.",
+    permissions => { check => [ 'admin', 'qmanager', 'audit', 'quser'] },
+    protected => 1,
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           pmail => $pmail_param_type,
+           address => get_standard_option('pmg-whiteblacklist-entry-list', {
+               pattern => '',
+               description => "The address you want to remove.",
+           }),
+       },
+    },
+    returns => { type => 'null' },
+    code => sub {
+       my ($param) = @_;
+
+       my $addresses = [split(',', $param->{address})];
+       $read_or_modify_user_bw_list->('WL', $param, $addresses, 1);
+
+       return undef;
+    }});
+
 __PACKAGE__->register_method ({
     name => 'whitelist_delete',
     path => 'whitelist/{address}',
@@ -356,6 +383,33 @@ __PACKAGE__->register_method ({
        return undef;
     }});
 
+__PACKAGE__->register_method ({
+    name => 'blacklist_delete_base',
+    path => 'blacklist',
+    method => 'DELETE',
+    description => "Delete user blacklist entries.",
+    permissions => { check => [ 'admin', 'qmanager', 'audit', 'quser'] },
+    protected => 1,
+    parameters => {
+       additionalProperties => 0,
+       properties => {
+           pmail => $pmail_param_type,
+           address => get_standard_option('pmg-whiteblacklist-entry-list', {
+               pattern => '',
+               description => "The address you want to remove.",
+           }),
+       },
+    },
+    returns => { type => 'null' },
+    code => sub {
+       my ($param) = @_;
+
+       my $addresses = [split(',', $param->{address})];
+       $read_or_modify_user_bw_list->('BL', $param, $addresses, 1);
+
+       return undef;
+    }});
+
 __PACKAGE__->register_method ({
     name => 'blacklist_delete',
     path => 'blacklist/{address}',