Nmap Development mailing list archives

Re: LDAP library and scripts


From: David Fifield <david () bamsoftware com>
Date: Tue, 2 Feb 2010 09:56:51 -0700

On Tue, Feb 02, 2010 at 04:22:08PM +0100, Patrik Karlsson wrote:
I was hoping to do a clean split between asn1, ldap and snmp.
Unfortunately the solution I chose sucks as once the libraries start
registering their encoders, they do it, as you pointed out, in a
global table. This wouldn't be an enormous problem IF there was NO
overlap.

But I wanted to split the ldap and snmp decoding/encoding into
ldap.lua and snmp.lua and keep only the basic encoding in asn1.lua
instead of mixing them together in the table decoder in asn1.lua. In
order to achieve this, in the current design, they both need to
register a decoder for the same tag. This is also the case for eg. the
snmp library that encodes booleans as asn null values.

So while the idea might have been OK to start with, the result
obviously isn't, so we're kind of back to square 1 where I'll be
needing to duplicate a lot of code from snmp.lua into ldap.lua in
order to get it working.

I still think making a clean split is a good design. There are other
ways to do it without mutating global state. For example, the encoding
functions could take an additional argument that is a table of custom
encoding functions. Or, you could instantiate individual encoder
objects, and each one of them could have its own table of custom
encoders. snmp would create one encoder, and ldap would create another.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: