12.07.2015 Views

The Computational Materials Repository

The Computational Materials Repository

The Computational Materials Repository

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.3 System Components and Processes 71victims machine when the file is opened.) <strong>The</strong> goal could be to get passwords,modify or delete content, install a virus, et cetera. In Python all functions thatinteract with the operating system or allow dynamic code execution (e.g. exec,eval, os.system, os.popen, execfile, input, compile) should not be used with datafrom the third-party input files. <strong>The</strong> only function that CMR uses when parsingthe third-party file is eval. This function is used to convert strings to numbers orarrays. Although potentially dangerous it is easy to sanitize eval by manually setthe local global environment as unavailable. This prevents eval from executingany code. <strong>The</strong> small code below demonstrates the effect: first the dangerousversion and then the sanitized one.# dangerouse v a l (” open ( ’ / tmp/new ’ , ’w ’ ) . w r i t e ( ’ a l e r t ’ ) ” )# s a n i t i z e de v a l (” open ( ’ / tmp/new ’ , ’w ’ ) . w r i t e ( ’ a l e r t ’ ) ” , { ’ b u i l t i n s ’ : None } , {})For more information about eval and python in general see [17].3.3.3.3 Schemas<strong>The</strong>re are two kinds of schemas: the CMR schema and the XML schema.(<strong>The</strong> database schema is of different nature and discussed in section 3.3.2.3.)<strong>The</strong> CMR schema is the main schema and defines for every calculator (andcalculator version) the fields, their types and units, if available. <strong>The</strong> XMLschema is derived from the CMR schema and used in order to perform the db-filevalidation (3.3.4.3).Purpose: <strong>The</strong> CMR schema is the description of the data in the db-file and isused during the extraction and during the validation.Implementation: <strong>The</strong> CMR schema is implemented in Python and defines allvariables stored in the corresponding db-file. Fig. 3.8 shows an extract of theGPAW schema. <strong>The</strong>se CMR schemas can be adapted to specific program versionsor they can be designed loose to accept several versions with the same schema.It is also possible to derive a schema from another one and make it specific for acertain type of calculation. One could imagine to make one for a chemisorptioncalculation where the atoms in the surface have to be put as separate fields.Example: section 2.9.33.3.4 Processes3.3.4.1 Conversion to /writing of a db-file<strong>The</strong> conversion process takes an original output file and converts it to a db-file.Purpose: Create db-files and define keywords/fields and attach scripts/files.Usage: <strong>The</strong> creation of the db-files is performed by the user with the CLI(3.3.1.1)or with the cmr Python package.Process: First the file type is detected and the correct converter determined. <strong>The</strong>converter is responsible to select the correct version of the CMR schema (3.3.3.3)depending on the version of the input file. When the data is read from the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!