Part of lp.codehosting.safe_open View In Hierarchy
Known subclasses: lp.codehosting.codeimport.worker.CodeImportBranchOpenPolicy, lp.codehosting.puller.worker.BranchMirrorerPolicy, lp.codehosting.safe_open.BlacklistPolicy, lp.codehosting.safe_open.SingleSchemePolicy, lp.codehosting.safe_open.WhitelistPolicy
In particular, a policy determines which branches are safe to open by checking their URLs and deciding whether or not to follow branch references.
Method | shouldFollowReferences | Whether we traverse references when mirroring. |
Method | transformFallbackLocation | Validate, maybe modify, 'url' to be used as a stacked-on location. |
Method | checkOneURL | Check the safety of the source URL. |
Subclasses must override this method.
If we encounter a branch reference and this returns false, an error is raised.
Returns | A boolean to indicate whether to follow a branch reference. |
Parameters | branch | The branch that is being opened. |
url | The URL that the branch provides for its stacked-on location. | |
Returns | (new_url, check) where 'new_url' is the URL of the branch to actually open and 'check' is true if 'new_url' needs to be validated by checkAndFollowBranchReference. |
Subclasses must override this method.
Parameters | url | The source URL to check. |
Raises | BadUrl | subclasses are expected to raise this or a subclass when it finds a URL it deems to be unsafe. |