Skip to content

Move away from eval in vocabulary mapping #94

@JessyBarrette

Description

@JessyBarrette

Issue

For some variable vocabularies, an apply_func parameter is defined to derive a new variable from the existing one. The defined apply_func value is then evaluated via eval() to generate a new variable. This can create some security risks which should ideally be mitigated.

This has for objectif to help standardizing the different variables variance to a same standard. Here's a quick list of the different functions applied:

  • lambda x: x/10: convert from S/m to mS/cm
  • lambda x: x*22.319/31.998 convert oxygen from mg/l to umol/l
  • lambda x: x*0.022391 convert form umol/l to ml/l
  • lambda x: -1*gsw.z_from_p(x,ds.attrs['latitude']) derive depth from sea pressure
  • lambda x: gsw.SP_from_SK(x) convert Knut salinity (g/kg) to practica salinity
  • lambda x: gsw.t90_from_t68(x) convert temperature in IPTS-68 to ITS-90
  • lambda x: 42.814*x/10 convert conductivity ration CRAT to S/m

The related vocabularies are the different DFO offices related ones:

Fix

A few possibilities regarding how to fix this issue:

  1. Create a dedicated function that essentially identify those problematic variables and apply a correction. The function can be either specific to each parser or more global. Likely the first may be easier to maintain in the future.
  2. Attempt to still use eval or an equivalent while fixing the security issues.

@sjbruce feel free to add anything in there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions