Allowlist bugs - developer returns

Hello,

I developed the Allowlist module sometime back and accidentally got locked out of the forum (password reset didn’t work for some reason. Anyway I recently retired and got a chance to re-look at the allowlist and found several bugs and a few feature opportunities.

I’d like to fix these and continue developing the module. How should I get back to that - pull requests through GitHub or are you still using the atlassian repository?

thanks!

Mitch Mitchell

One thing that I have noticed (you may already be aware), when a destination is already set, and you select ==choose one == I get:

Whoops...

 if (isset($request['goto0']))
        {
            $destination = $request[$request['goto0'] . '0'];
        } 
...

Replace $destination = $request[$request['goto0'] . '0']; with:

$destination = $request[$request['goto0'] . '0'] ?? '';

And it should fix it and not show the whoops.
The fix also sends callers to blackhole instead of previously programmed destination.

Multiple Allowlist lists would be a nice addition.

Thanks @madgen, good catch, and thanks for the fix.

I’ve confirmed it in the current 17.0 code (`Allowlist.class.php`, `doConfigPageInit()`). When “== choose one ==” is selected, `goto0` is posted empty, so the code looks up `$request[‘0’]`, which doesn’t exist. PHP 8 warns about the missing key and FreePBX shows the Whoops page.

Your `?? ‘’` fixes that case. There’s a second one: if `goto0` isn’t posted at all, `$destination` is never set before `destinationSet($destination)` is called. This version covers both:

```php

$destination = ‘’;

if (isset($request[‘goto0’]))

{

$destination = $request\[$request\['goto0'\] . '0'\] ?? '';

}

```

About callers going to blackhole after the fix: that comes from the fix working. Choosing “== choose one ==” now saves “no destination” and deletes the old one. With no destination set, the dialplan falls back to `app-blackhole,hangup,1`, so callers who aren’t on the list are hung up on. Before, the error stopped the save, so the old destination survived by accident. I’ll either require a destination or keep the existing one when none is picked, so that can’t happen silently.

**Multiple allowlists:** agreed, and it’s planned. Rough scope:

- Named lists, with current entries moved into a `default` list on upgrade so nothing changes for existing setups

- Each inbound route chooses which list to check

- Each outbound route with auto-add chooses which list to add to

- Optional destination per list, falling back to the global one

- Feature codes, `fwconsole allowlist`, the API, bulk import/export and backup/restore all made aware of lists

If you have opinions on any of these, please share:

1. Should a caller on *any* list get through, or only one on the list chosen for that inbound route?

2. How should the feature codes (*38–*40) pick a list: one code per list, or always the default list?

3. Should pause stay global or apply to each list?

I’ve also been through the rest of the 17.0 code and found several other bugs. Fixes for those will come along with this one.

Mitch,
You’re welcome. Glad it worked out.

  1. Maybe have a global (as it is) list and a per inbound list?
  2. If possible *38xx where xx= the list id. maybe 00 = global?
  3. Same as 2. *41xx where xx= the list id.

Maybe something like this?

/allowlist/01/2125551212                             : Adam Cell
/allowlist/01/6465550599                             : Veronica Home
/allowlist/01/dest                                   : app-announcement-1,s,1
/allowlist/01/did/                                   : 1
/allowlist/01/did/7085550200                         : 1
/allowlist/02/4575551212                             : Stan Cell
/allowlist/02/4675554444                             : Bob Jones
/allowlist/02/dest                                   : app-blackhole,hangup,1
/allowlist/02/did/                                   : 1
/allowlist/02/did/7085550201                         : 1

It will be something like that where the current allowlist becomes the global one. I’m still setting up the dev environment for my grok bots but they’ve started development already.

Not a feature I’ve used. Is it the “Whitelist” equivalent for the Blacklist module?

Essentially but implemented entirely in FreePBX instead of in asterisk like the blacklist module