URL: https://github.com/freeipa/freeipa/pull/590
Author: Akasurde
 Title: #590: Validate user input for cert-get-requestdata
Action: opened

PR body:
"""
Fix adds validatation for Principal and CSR generation
tool values

Fixes https://pagure.io/freeipa/issue/6742

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/590/head:pr590
git checkout pr590
From f2f417d1c6b9c52ba769a50c10c107be0a7f1211 Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasu...@redhat.com>
Date: Wed, 15 Mar 2017 12:12:56 +0530
Subject: [PATCH] Validate user input for cert-get-requestdata

Fix adds validatation for Principal and CSR generation
tool values

Fixes https://pagure.io/freeipa/issue/6742

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
---
 ipaclient/plugins/csrgen.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ipaclient/plugins/csrgen.py b/ipaclient/plugins/csrgen.py
index a0d99ef..3bae7f8 100644
--- a/ipaclient/plugins/csrgen.py
+++ b/ipaclient/plugins/csrgen.py
@@ -75,10 +75,19 @@ def execute(self, *args, **options):
             util.check_writable_file(options['out'])
 
         principal = options.get('principal')
+        if principal is None:
+            raise errors.InvocationError(message=u"Principal is required")
         profile_id = options.get('profile_id')
         if profile_id is None:
             profile_id = dogtag.DEFAULT_PROFILE
         helper = options.get('helper')
+        if helper is None:
+            raise errors.InvocationError(message=u"CSR generation tool is"
+                                                 "required")
+        if helper.lower() not in ['openssl', 'certutil']:
+            raise errors.InvocationError(message=u"Allowed values for CSR "
+                                                 "generation "
+                                                 "tool are (openssl/certutil)")
 
         if self.api.env.in_server:
             backend = self.api.Backend.ldap2
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to