Bug 32306 - [Syntax] TrueFalse allows any value on CLI
[Syntax] TrueFalse allows any value on CLI
Status: RESOLVED DUPLICATE of bug 40731
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UNSTABLE
Other Linux
: P5 normal (vote)
: UCS 3.x
Assigned To: UMC maintainers
:
: 35023 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-22 13:59 CEST by Lukas Walter
Modified: 2018-04-13 13:29 CEST (History)
4 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Walter univentionstaff 2013-08-22 13:59:16 CEST
I can pass any value to TrueFalse attributes on CLI and they get applied:
=========================================================================
root@master200:~# udm policies/dhcp_dnsupdate create --set name="some_policy" --set ddnsDoForwardUpdate="neither_true_nor_false"
Object created: cn=some_policy,dc=ucs,dc=dev
root@master200:~# univention-ldapsearch cn=some_policy
# extended LDIF
#
# LDAPv3
# base <dc=ucs,dc=dev> (default) with scope subtree
# filter: cn=some_policy
# requesting: ALL
#

# some_policy, ucs.dev
dn: cn=some_policy,dc=ucs,dc=dev
objectClass: top
objectClass: univentionPolicy
objectClass: univentionPolicyDhcpDnsUpdate
objectClass: univentionObject
univentionDhcpDoForwardUpdates: neither_true_nor_false
univentionObjectType: policies/dhcp_dnsupdate
cn: some_policy
========================================================================

This might be a general problem of the IState syntax TrueFalse, which just returns the given value if no valid one was found or the value is an instance of "basestring".
Comment 1 Lukas Walter univentionstaff 2013-08-22 14:00:33 CEST
> This might be a general problem of the IState syntax TrueFalse, which just
                                                       ^^^^^^^^^
                                                       ignore this
Comment 2 Alexander Kläser univentionstaff 2013-08-23 14:08:52 CEST
As you said, it seems that the parse method accepts any value... has this been done intentionally this way?

====================
class IStates( select ):
    values = []

    @ClassProperty
    def choices( cls ):
        return map( lambda x: ( x[ 1 ] ), cls.values )

    @classmethod
    def parse( cls, text ):
        if isinstance( text, basestring ):
            return text
        for value, choice in cls.values:
            if text == value:
                return choice[ 0 ]
        return text

class TrueFalse( IStates ):
    values = (
        ( None, ( '', '' ) ),
        ( True, ( 'true', _('True') ) ),
        ( False, ( 'false', _('False')) )
    )
====================
Comment 3 Alexander Kläser univentionstaff 2013-08-23 14:33:17 CEST
I could find the following occurrences:

> handlers/policies/release.py:         syntax=univention.admin.syntax.TrueFalseUp,
> handlers/policies/pwhistory.py:           syntax=univention.admin.syntax.TrueFalseUp,
> handlers/policies/dhcp_dnsupdate.py:          syntax=univention.admin.syntax.ddnsUpdates,
> handlers/policies/dhcp_dnsupdate.py:          syntax=univention.admin.syntax.TrueFalse,
> handlers/policies/dhcp_dnsupdate.py:          syntax=univention.admin.syntax.TrueFalse,
> handlers/policies/dhcp_dnsupdate.py:          syntax=univention.admin.syntax.AllowDeny,
> handlers/policies/dhcp_scope.py:          syntax=univention.admin.syntax.AllowDenyIgnore,
> handlers/policies/dhcp_scope.py:          syntax=univention.admin.syntax.AllowDenyIgnore,
> handlers/policies/dhcp_scope.py:          syntax=univention.admin.syntax.AllowDenyIgnore,
> handlers/policies/dhcp_scope.py:          syntax=univention.admin.syntax.AllowDeny,
> handlers/policies/dhcp_scope.py:          syntax=univention.admin.syntax.AllowDenyIgnore,
> handlers/policies/dhcp_statements.py:         syntax=univention.admin.syntax.booleanNone,
> handlers/policies/dhcp_statements.py:         syntax=univention.admin.syntax.TrueFalse,
> handlers/policies/dhcp_statements.py:         syntax=univention.admin.syntax.TrueFalse,
> handlers/policies/dhcp_statements.py:         syntax=univention.admin.syntax.TrueFalse,
> handlers/settings/syntax.py:              syntax = univention.admin.syntax.TrueFalseUp,
> handlers/settings/syntax.py:              syntax=univention.admin.syntax.TrueFalseUp,
> handlers/dhcp/pool.py:            syntax=univention.admin.syntax.AllowDeny,
> handlers/dhcp/pool.py:            syntax=univention.admin.syntax.AllowDeny,
> handlers/dhcp/pool.py:            syntax=univention.admin.syntax.AllowDeny,
> handlers/dhcp/pool.py:            syntax=univention.admin.syntax.AllowDeny,
Comment 4 Alexander Kläser univentionstaff 2013-08-23 14:38:51 CEST
Revision 26262 introduced syntax IState and converted several syntax classes to IState (they used to be childs of syntax class select):

> * all boolean syntax classes provide a mapping between the string
>   representation and the boolean value; Bug #23222

If I see it correctly, any string is accepted in the parse method, this should be wrong (and differs from the behaviour of the previously used select class):

>      def parse( cls, text ):
>         if isinstance( text, basestring ):
>             return text
Comment 5 Alexander Kläser univentionstaff 2014-06-05 23:08:20 CEST
*** Bug 35023 has been marked as a duplicate of this bug. ***
Comment 6 Florian Best univentionstaff 2016-07-14 09:07:49 CEST

*** This bug has been marked as a duplicate of bug 40731 ***