Nmap Development mailing list archives
Re: LDAP library and scripts
From: David Fifield <david () bamsoftware com>
Date: Tue, 2 Feb 2010 10:10:27 -0700
On Tue, Feb 02, 2010 at 09:56:51AM -0700, David Fifield wrote:
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.
Another idea is that you don't need one all-powerful asn1.encode function. You could provide only lower-level functions, like asn1.encodeInt, asn1.encodeBoolean, asn1.encodeSequenceOf, and have snmp and ldap use those. Other libraries would contain any application-specific encoders that they need. (Of course what I'm saying about encoders applies equally to decoders.) 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:
- LDAP library and scripts Patrik Karlsson (Jan 12)
- Re: LDAP library and scripts David Fifield (Jan 25)
- Re: LDAP library and scripts Patrik Karlsson (Jan 28)
- Re: LDAP library and scripts David Fifield (Feb 01)
- Re: LDAP library and scripts Patrik Karlsson (Feb 02)
- Re: LDAP library and scripts David Fifield (Feb 02)
- Re: LDAP library and scripts David Fifield (Feb 02)
- Re: LDAP library and scripts Patrik Karlsson (Feb 03)
- Re: LDAP library and scripts David Fifield (Feb 14)
- Re: LDAP library and scripts Patrik Karlsson (Jan 28)
- Re: LDAP library and scripts Patrik Karlsson (Feb 02)
- Re: LDAP library and scripts David Fifield (Jan 25)