Re: Streamlined application/script development [Re: coding an Application in perl]

Jean-Louis Martineau <[email protected]> Wed, 13 Sep 2017 13:10:08 -0400
Newsgroups gmane.comp.archivers.amanda.devel
Message-ID <[email protected]>
On 12/09/17 01:06 PM, Chapman Flack wrote:
> On 09/12/2017 07:58 AM, Jean-Louis Martineau wrote:
>> For read_local_state and write_local_state,
>>
>> Why do not simply use Data::Dumper to write the data and eval to parse
> That would work, and I have written things in Python that use repr
> to write and ast.literal_eval to parse. I like that Python provides
> an explicitly limited literal_eval - I am not as comfortable with
> slurping up a file I think should be data and throwing full eval()
> at it. As a practical matter, if the state files always live somewhere
> only Amanda can write them, the exploit risk should be minimal or
> at least no-worse-than-various-other-things, but I am happier to bar it
> outright.
>
> I also think it's worthwhile to have the application author give
> some specification of what should be in the state, and do at least
> a little bit of automated validation. It helps the application author
> have more confidence in early testing that the stuff is as expected,
> and gives others reading the code an easy place to look and see
> what information is carried in the state.
>
> If JSON or XML libraries were in core and supported JSON or XML schemas,
> I would probably have gone that way. A Getopt::Long spec is less
> flexible than JSON Schema or XML Schema, but it is enough to cover
> simple numbers and strings, and has the advantage of being familiar
> already to an application author (who has to know it for application
> arguments already), where another schema language could be something
> else to learn.

Amanda already require the perl JSON module, so you can use it.

Jean-Louis
This message is the property of CARBONITE, INC. and may contain confidential or privileged information.
If this message has been delivered to you by mistake, then do not copy or deliver this message to anyone.  Instead, destroy it and notify me by reply e-mail