[pmg-devel] [PATCH pmg-api 1/1] add better api call for user white/blacklist deletion

Dominik Csapak d.csapak at proxmox.com
Mon Mar 9 12:18:16 CET 2020


having the entry as part of the url causes many problems since
it can contain special characters like '/.,' etc.

having it as parameter makes it easier and safer to use

note that the new api calls have a pattern of '' so no limits
for the entries

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PMG/API2/Quarantine.pm | 54 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
index 5cb0f8e..272dfdb 100644
--- a/src/PMG/API2/Quarantine.pm
+++ b/src/PMG/API2/Quarantine.pm
@@ -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}',
-- 
2.20.1




More information about the pmg-devel mailing list