Module defining pyHanko’s standard difference policy implementation.
- class pyhanko.sign.diff_analysis.policies.StandardDiffPolicy(global_rules: List[pyhanko.sign.diff_analysis.rules_api.QualifiedWhitelistRule], form_rule: Optional[pyhanko.sign.diff_analysis.form_rules_api.FormUpdatingRule], reject_object_freeing=True, ignore_orphaned_objects=True)
Run a list of rules to analyse the differences between two revisions.
global_rules – The
QualifiedWhitelistRuleobjects encoding the rules to apply.
form_rule – The
FormUpdatingRulethat adjudicates changes to form fields and their values.
Always fail revisions that free objects that existed prior to signing.
PyHanko resolves freed references to the
nullobject in PDF, and a freeing instruction in a cross-reference section is always registered as a change that needs to be approved, regardless of the value of this setting.
It is theoretically possible for a rule to permit deleting content, in which case allowing objects to be freed might be reasonable. That said, pyHanko takes the conservative default position to reject all object freeing instructions as suspect.
ignore_orphaned_objects – Some PDF writers create objects that aren’t used anywhere (tsk tsk). Since those don’t affect the “actual” document content, they can usually be ignored. If
True, newly created orphaned objects will be cleared at level
ModificationLevel.LTA_UPDATES. Default is
- apply(old: pyhanko.pdf_utils.reader.HistoricalResolver, new: pyhanko.pdf_utils.reader.HistoricalResolver, field_mdp_spec: Optional[pyhanko.sign.fields.FieldMDPSpec] = None, doc_mdp: Optional[pyhanko.sign.fields.MDPPerm] = None) pyhanko.sign.diff_analysis.policy_api.DiffResult
Execute the policy on a pair of revisions, with the MDP values provided.
SuspiciousModificationexceptions should be propagated.
old – The older, base revision.
new – The newer revision.
field_mdp_spec – The field MDP spec that’s currently active.
doc_mdp – The DocMDP spec that’s currently active.
DiffResultobject summarising the policy’s judgment.
- review_file(reader: pyhanko.pdf_utils.reader.PdfFileReader, base_revision: Union[int, pyhanko.pdf_utils.reader.HistoricalResolver], field_mdp_spec: Optional[pyhanko.sign.fields.FieldMDPSpec] = None, doc_mdp: Optional[pyhanko.sign.fields.MDPPerm] = None) Union[pyhanko.sign.diff_analysis.policy_api.DiffResult, pyhanko.sign.diff_analysis.policy_api.SuspiciousModification]
DiffPolicy.review_file()that reviews each intermediate revision between the base revision and the current one individually.
- pyhanko.sign.diff_analysis.policies.DEFAULT_DIFF_POLICY = <pyhanko.sign.diff_analysis.policies.StandardDiffPolicy object>
This policy includes the following rules, all with the default settings. The unqualified rules in the list all have their updates qualified at level