[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9498?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15508752#comment-15508752
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9498:
--------------------------------------------

GitHub user murali-reddy opened a pull request:

    https://github.com/apache/cloudstack/pull/1680

    CLOUDSTACK-9498: VR CsFile search utility methods fail when search st…

    
    There is no real use of python 're' module  in CsFile.py utility methods 
searchString, deleteLine. Regular string search is sufficient. These methods 
are used only for VPN user add/delete. Since VPN user password can have python 
're' module meta characters, it interfere with search functionality.
    
    Replacing re.search() with regular string search instead.
    
    Change is confined to VPN add/delete users. Have run the 
test/integration/component/test_vpn_users.py
    
    VPN remote access user limit tests ... === TestName: test_01_VPN_user_limit 
| Status : SUCCESS ===
    ok
    Test create VPN when L2TP port in use ... === TestName: 
test_02_use_vpn_port | Status : SUCCESS ===
    ok
    Test create NAT rule when VPN when L2TP enabled ... === TestName: 
test_03_enable_vpn_use_port | Status : SUCCESS ===
    ok
    Test add new users to existing VPN ... === TestName: test_04_add_new_users 
| Status : SUCCESS ===
    ok
    Test add duplicate user to existing VPN ... === TestName: 
test_05_add_duplicate_user | Status : SUCCESS ===
    ok
    Test as global admin, add a new VPN user to an existing VPN entry ... === 
TestName: test_06_add_VPN_user_global_admin | Status : SUCCESS ===
    ok
    Test as domain admin, add a new VPN user to an existing VPN entry ... === 
TestName: test_07_add_VPN_user_domain_admin | Status : SUCCESS ===
    ok

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/murali-reddy/cloudstack vr_csfile_search

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/1680.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1680
    
----
commit 352835873279ae966f889b290ff79587dcea1c11
Author: Murali Reddy <muralimmre...@gmail.com>
Date:   2016-09-20T20:39:16Z

    CLOUDSTACK-9498: VR CsFile search utility methods fail when search string 
has char *, + etc
    
    there is no real use of python 're' in CsFile.py utility methods 
searchString, deleteLine
    Replacing with regular string search instead.

----


> VR CsFile search utility methods fail when search string has char *, + etc
> --------------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9498
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9498
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>    Affects Versions: 4.6.2, 4.7.1, 4.8.0, 4.8.1, 4.9.0
>            Reporter: Murali Reddy
>            Assignee: Murali Reddy
>             Fix For: 4.10.0.0, 4.9.1.0, 4.8.2.0
>
>
> VR CsFile search utility methods fail when search string has char *, + etc.
> These utility methods in CsFile [1] uses python regular expression module to 
> search a string in a file. However, if caller passes a search string, that 
> has chars *, +, . etc that are also happen to be express wild card / match 
> expression in regular expression results in exceptions from python 're' 
> module.
> For instance searching for VPN user [2] passes "username * password *" as 
> search string, if password has chars the interfer with regular expression 
> metacharecters then search will result in exception.
> 2016-09-12 13:55:48,976 configure.py add_l2tp_ipsec_user:569 Adding vpn user 
> murali * abcd++efgh## *
> 2016-09-12 13:55:48,976 CsFile.py load:39 Reading file /etc/ppp/chap-secrets
> 2016-09-12 13:55:48,976 CsFile.py searchString:140 Searching for murali * 
> abcd++efgh## * string
> 2016-09-12 13:55:48,976 configure.py main:1020 Exception while configuring 
> router
> Traceback (most recent call last):
> File "/opt/cloud/bin/configure.py", line 965, in main
> vpnuser.process()
> File "/opt/cloud/bin/configure.py", line 559, in process
> self.add_l2tp_ipsec_user(user, userconfig)
> File "/opt/cloud/bin/configure.py", line 572, in add_l2tp_ipsec_user
> userfound = file.searchString(userSearchEntry, '#')
> File "/opt/cloud/bin/cs/CsFile.py", line 146, in searchString
> if re.search(search, line):
> File "/usr/lib/python2.7/re.py", line 142, in search
> return _compile(pattern, flags).search(string)
> File "/usr/lib/python2.7/re.py", line 242, in _compile
> raise error, v # invalid expression
> 1 
> https://github.com/apache/cloudstack/blob/master/systemvm/patches/debian/config/opt/cloud/bin/cs/CsFile.py
> 2 
> https://github.com/apache/cloudstack/blob/master/systemvm/patches/debian/config/opt/cloud/bin/configure.py#L572



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to