You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reject line breaks in attribute types read from column comments #1711
DataJoint records each attribute's declared type, such as int32 or <blob>, at the start of the column's comment in the database (:type:comment). Heading reads it back with
(src/datajoint/heading.py, line 525 on master and next). [^:]+ also matches line breaks, so the type read from a comment can span several lines. Nothing downstream checks it:
For a codec type (<...>), the multi-line text fails the codec pattern and stays in attr.type.
For a core type, it goes to attr.original_type.
Job._generate_definition (src/datajoint/jobs.py, line 216) writes name : <original_type or type> for each inherited primary-key attribute. So a line break in a column comment adds lines to the jobs table's definition.
Since 2.3.6, foreign-key references are never evaluated, so the added lines cannot run code; see GHSA-gmj8-m8g8-9wg9. They can still add attributes or references to the jobs table definition, or make creating the jobs table fail.
Proposed fix
Read the type with a pattern that excludes line breaks, for example :(?P<type>[^:\n\r]+):.
Accept a type from a comment only if it matches a known core type or the codec pattern. Otherwise treat the whole comment as a plain comment.
Have Job._generate_definition refuse any attribute name or type that contains a line break, with a DataJointError that names the table and attribute.
Tests
A column comment :int32 + line break + -> Other: on an inherited primary-key attribute does not add a line to Job(table).definition.
The same with :<blob> + line break.
Ordinary comments, core types and codec types still round-trip through describe().
Activity