Module defining API types for use by form analysis rules.
In principle, these aren’t relevant to the high-level validation API.
- class pyhanko.sign.diff_analysis.form_rules_api.FormUpdatingRule(field_rules: List[FieldMDPRule], ignored_acroform_keys=None)
Special whitelisting rule that validates changes to the form attached to the input document.
This rule is special in two ways:
FormUpdateobjects instead of references;
it delegates most of the hard work to sub-rules (instances of
FormUpdateobjects contain a reference plus metadata about the form field it belongs to.
field_rules – A list of
FieldMDPRuleobjects to validate the individual form fields.
ignored_acroform_keys – Keys in the
/AcroFormdictionary that may be changed. Changes are potentially subject to validation by other rules.
- class pyhanko.sign.diff_analysis.form_rules_api.FormUpdate(updated_ref: Reference, context_checked: Optional[Context] = None, field_name: Optional[str] = None, valid_when_locked: bool = False, valid_when_certifying: bool = True)
Container for a reference together with (optional) metadata.
Currently, this metadata consists of the relevant field’s (fully qualified) name, and whether the update should be approved or not if said field is locked by the FieldMDP policy currently in force.
- field_name: Optional[str] = None
The relevant field’s fully qualified name, or
Noneif there’s either no obvious associated field, or if there are multiple reasonable candidates.
- valid_when_locked: bool = False
Flag indicating whether the update is valid even when the field is locked. This is only relevant if
- valid_when_certifying: bool = True
Flag indicating whether the update is valid when checking against an explicit DocMDP policy. Default is
False, the change will only be accepted if we are evaluating changes to a document after an approval signature.
- class pyhanko.sign.diff_analysis.form_rules_api.FieldMDPRule
Sub-rules attached to a
- class pyhanko.sign.diff_analysis.form_rules_api.FieldComparisonSpec(field_type: str, old_field_ref: Optional[Reference], new_field_ref: Optional[Reference], old_canonical_path: Optional[RawPdfPath])
Helper object that specifies a form field name together with references to its old and new versions.
- field_type: str
The (fully qualified) form field name.
- old_field_ref: Optional[Reference]
A reference to the field’s dictionary in the old revision, if present.
- new_field_ref: Optional[Reference]
A reference to the field’s dictionary in the new revision, if present.
- old_canonical_path: Optional[RawPdfPath]
Path from the trailer through the AcroForm structure to this field (in the older revision). If the field is new, set to
- property old_field: Optional[DictionaryObject]
The field’s dictionary in the old revision, if present, otherwise
- property new_field: Optional[DictionaryObject]
The field’s dictionary in the new revision, if present, otherwise
- class pyhanko.sign.diff_analysis.form_rules_api.FieldComparisonContext(field_specs: Dict[str, FieldComparisonSpec], old: HistoricalResolver, new: HistoricalResolver)
Context for a form diffing operation.
- field_specs: Dict[str, FieldComparisonSpec]
Dictionary mapping field names to