]> git.proxmox.com Git - pmg-api.git/blobdiff - PMG/Config.pm
add custom_check handling
[pmg-api.git] / PMG / Config.pm
index a3fa4ace73d59979fd12e057776123ab6717cf93..21bc204ff9b277162eb14b5318bc70621b998fab 100755 (executable)
@@ -15,7 +15,7 @@ my $defaultData = {
     propertyList => {
        type => { description => "Section type." },
        section => {
-           description => "Secion ID.",
+           description => "Section ID.",
            type => 'string', format => 'pve-configid',
        },
     },
@@ -102,6 +102,16 @@ sub properties {
            type => 'boolean',
            default => 1,
        },
+       custom_check => {
+           description => "Use Custom Check Script. The script has to take the defined arguments and can return Virus findings or a Spamscore.",
+           type => 'boolean',
+           default => 0,
+       },
+       custom_check_path => {
+           description => "Absolute Path to the Custom Check Script",
+           type => 'string', pattern => '^/([^/\0]+\/)+[^/\0]+$',
+           default => '/usr/local/bin/pmg-custom-check',
+       },
     };
 }
 
@@ -115,6 +125,8 @@ sub options {
        demo => { optional => 1 },
        email => { optional => 1 },
        http_proxy => { optional => 1 },
+       custom_check => { optional => 1 },
+       custom_check_path => { optional => 1 },
     };
 }
 
@@ -157,7 +169,7 @@ sub properties {
            type => 'string',
        },
        clamav_heuristic_score => {
-           description => "Score for ClamaAV heuristics (Google Safe Browsing database, PhishingScanURLs, ...).",
+           description => "Score for ClamAV heuristics (Google Safe Browsing database, PhishingScanURLs, ...).",
            type => 'integer',
            minimum => 0,
            maximum => 1000,
@@ -319,7 +331,7 @@ sub properties {
            default => 'database.clamav.net',
        },
        archiveblockencrypted => {
-           description => "Wether to block encrypted archives. Mark encrypted archives as viruses.",
+           description => "Whether to block encrypted archives. Mark encrypted archives as viruses.",
            type => 'boolean',
            default => 0,
        },
@@ -959,13 +971,17 @@ sub pmg_verify_tls_policy {
     return $policy;
 }
 
-sub pmg_verify_tls_policy_strict {
-    my ($policy) = @_;
+PVE::JSONSchema::register_format(
+    'tls-policy-strict', \&pmg_verify_tls_policy_strict);
 
-    return $policy
-       if ($policy =~ /^$VALID_TLS_POLICY_RE$/);
+sub pmg_verify_tls_policy_strict {
+    my ($policy, $noerr) = @_;
 
-    return undef;
+    if ($policy !~ /^$VALID_TLS_POLICY_RE$/) {
+       return undef if $noerr;
+       die "value '$policy' does not look like a valid tls policy\n";
+    }
+    return $policy;
 }
 
 sub read_tls_policy {