Bug 2017411

Summary: cockpit crashes because invalid SASL mapping regex was saved
Product: Red Hat Directory Server Reporter: sgouvern
Component: cockpit-389-dsAssignee: mreynolds
Status: CLOSED ERRATA QA Contact: LDAP QA Team <idm-ds-qe-bugs>
Severity: medium Docs Contact:
Priority: high    
Version: 12.0CC: idm-ds-dev-bugs, mreynolds, pasik, vashirov
Target Milestone: DS12.0Keywords: Triaged
Target Release: dirsrv-12.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: redhat-ds-12-9020020221130212339.1674d57 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-30 09:40:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sgouvern 2021-10-26 13:19:34 UTC
Description of problem:
Editing an existing SASL mapping, you can change the SASL mapping regular expression and enter an invalid mapping. You can then save it without problem.

But then entering a random expression in 'test regex' will make cockpit crash 


Version-Release number of selected component (if applicable):
cockpit-389-ds-2.0.10-1.module+el9dsrv+12668+daa4c88c.noarch


How reproducible:
always

Steps to Reproduce:
1.Go to 'Server settings' / 'SASL settings and mappings'
2.In 'SASL mappings' table, click on the 3 points on the right and Edit mapping
3. Change the SASL mapping Regular Expression to something invalid
4. Click 'Save mapping'
5. Now enter a random expression in 'Test regex' and click 'Test it'

Actual results:
cockpit crashes : Ooops!  appears in red a the top right 

console details :
CMD: editMapping: Create new sasl mapping ==> dsconf -j ldapi://%2fvar%2frun%2fslapd-inst2.socket sasl create --cn=Kerberos uid mapping --nsSaslMapFilterTemplate=(uid=\1) --nsSaslMapRegexString=\(.*\)@\(.*\ --nsSaslMapBaseDNTemplate=dc=\2,dc=\3 --nsSaslMapPriority=100 index.js:2:373530
CMD: loadConfig: Get SASL settings ==> dsconf -j ldapi://%2fvar%2frun%2fslapd-inst2.socket config get index.js:2:373530
CMD: loadMechs: Get supported SASL mechanisms ==> dsconf -j ldapi://%2fvar%2frun%2fslapd-inst2.socket sasl get-mechs index.js:2:373530
CMD: get_and_set_sasl: Get SASL mappings ==> dsconf -j ldapi://%2fvar%2frun%2fslapd-inst2.socket sasl list --details index.js:2:373530
Uncaught SyntaxError: \ at end of pattern
    handleTestRegex https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    o https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    u https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    v https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    v https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    ot https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    it https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    lt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    mt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    j https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    H https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Qt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Xt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    unstable_runWithPriority https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Gr https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    L https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Jt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
index.js:2:2093132
    handleTestRegex https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    handleTestRegex self-hosted:1181
    o https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    u https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    v https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    v https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    ot https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    it https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    lt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    mt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    j https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    H https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Qt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Xt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    bind_applyFunctionN self-hosted:1379
    Xt self-hosted:1342
    unstable_runWithPriority https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Gr https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    L https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    Jt https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.js:2
    bind_applyFunctionN self-hosted:1379
    Jt self-hosted:1342
Source map error: Error: request failed with status 404
Resource URL: https://10.0.139.73:9090/cockpit/$70a6d3a5f63719992776a2df7d3f70f8788f3bc6be0cc6a7013e46962514e407/389-console/index.css
Source Map URL: index.css.map

Expected results:
SASL mapping Regular expression is checked and rejected if invalid
cockpit does not crash


Additional info:

Comment 4 sgouvern 2022-02-18 21:31:51 UTC
With cockpit-389-ds-2.0.14-2.module+el9dsrv+14105+a1e450bc.noarch

In some cases, invalid regular expressions are now detected and a warning message is displayed : 'You must provide a valid regular expression'
In such cases, cockpit will behave correctly, no more crash, and testing a test regex will result in an error message be displayed 'Invalid regular expression' 

But there are still cases where invalid regular expression is not detected, for example \(.*\)@\(.*\)\.
In this case a Ooops! red message is displayed at the top of the page : 'Cockpit had an unexpected internal error.You can try restarting Cockpit by pressing refresh in your browser.'

Even if the issue is minor, as despite this Ooops! unexpected error everything seem to be still working correctly, it may be alarming for the user.

Comment 5 mreynolds 2022-02-24 19:14:21 UTC
I can not reproduce the crash, and it was not clear what the exact regex was (did it have a trailing period or was that to indicate the end of the sentence?).

I tried:

    \(.*\)@\(.*\)\     --> this is rejected by UI as an invalid regex, and it does not allow me to save it or test it.

and

    \(.*\)@\(.*\)\.    --> This is accepted by the UI, and does not cause any crashes either saving it or testing it.


Sylvie, what steps am I missing?

Comment 6 sgouvern 2022-02-28 16:58:35 UTC
Mark, I could reproduce editing the Kerberos uid mapping, suppressing the 2 last characters of regex : \(.*\)@\(.*\)\.\(.*

The invalid regex is not detected (no error message 'you must provide a valid regular expression' displayed)

Then entering random characters in test regex, for example cn=fgsgf, and clicking on 'Test it' 
will result in a Oooops! red message displayed at the top of the window :  Unexpected error. Cockpit had an unexpected internal error. You can try restarting Cockpit by pressing refresh in your browser. The javascript console contains details about this error (Ctrl-Shift-J in most browsers).

Comment 9 mreynolds 2022-11-17 20:36:35 UTC
(In reply to sgouvern from comment #8)
> With cockpit-389-ds-2.0.14-6, the Bz is still Failed QA.
> The crash can be reproduced editing the Kerberos uid mapping, suppressing
> the 2 last characters of regex : 
> Regular Expression : \(.*\)@\(.*\)\.\(.*
> Test Regex / Test it -> Ooops! ... Cockpit had an unexpected internal error
> ...
> 
> It is not able to detect that the regex is invalid in this case ^^ ('you
> must provide a valid regular expression' is *not* displayed)
> 
> BTW I understand that with this commit :
> https://github.com/389ds/389-ds-base/commit/
> b5c24f5a6316d318998d62fbd5e056aa5edb36e0 the 'Test' button should be
> disabled if the regex is invalid, which is not the case

With the latest version of UI, and latest npm packages, this problem is no longer reproducible.

Comment 12 Viktor Ashirov 2023-02-20 12:00:10 UTC
Build tested:
389-ds-base-2.2.6-1.module+el9dsrv+17949+63c5b04e.x86_64
cockpit-389-ds-2.2.6-1.module+el9dsrv+17949+63c5b04e.noarch

I can no longer reproduce the crash. "Test It" button also stays grayed out when the regex is incorrect.

Marking as VERIFIED.

Comment 14 errata-xmlrpc 2023-05-30 09:40:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (redhat-ds:12 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:3344