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:
- 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.
- Attempt to still use eval or an equivalent while fixing the security issues.
@sjbruce feel free to add anything in there.
Issue
For some variable vocabularies, an
apply_funcparameter is defined to derive a new variable from the existing one. The defined apply_func value is then evaluated viaeval()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/cmlambda x: x*22.319/31.998convert oxygen from mg/l to umol/llambda x: x*0.022391convert form umol/l to ml/llambda x: -1*gsw.z_from_p(x,ds.attrs['latitude'])derive depth from sea pressurelambda x: gsw.SP_from_SK(x)convert Knut salinity (g/kg) to practica salinitylambda x: gsw.t90_from_t68(x)convert temperature in IPTS-68 to ITS-90lambda x: 42.814*x/10convert conductivity ration CRAT to S/mThe related vocabularies are the different DFO offices related ones:
Fix
A few possibilities regarding how to fix this issue:
@sjbruce feel free to add anything in there.