Troubleshooting
Problem
I am trying to create a new computed attribute using grdapi create_computed_attribute command. It fails with an error: ERR=2410 Error Creating New Computed Attribute - Invalid Expression Or expression includes not allowed characters
Cause
The following characters and words are not allowed in computed attributes, to prevent SQL injection:
INSERT, UPDATE, DELETE, TRUNCATE, ALTER, CREATE, DROP, ;, --, /*
If your computed attribute expression contains one of the above, then it will fail with this error.
Resolving The Problem
To resolve the problem, the computed attribute expression must be rewritten to avoid those characters. In most cases, this should be possible. The mysql char() function can be used to replace characters.
Problem example with semicolon
guardium> grdapi create_computed_attribute attributeLabel="app_user" entityLabel="Access Period" expression="SUBSTRING_INDEX(APP_USER_NAME,';',1)"
create_computed_attribute:
ERR=2410
Error Creating New Computed Attribute - Invalid Expression Or
expression includes not allowed characters
Working example with char(59)
guardium> grdapi create_computed_attribute attributeLabel="app_user" entityLabel="Access Period" expression="SUBSTRING_INDEX(APP_USER_NAME,char(59),1)"
ID=20000
Attribute for Expression SUBSTRING_INDEX(APP_USER_NAME,char(59),1) Created
Mysql char() function reference
Character(s) | Char() equivalent |
; | char(59) |
-- | char(45,45) |
/* | char(47,42) |
Related Information
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21997863