(self, manifest, key)
| 167 | fd.write(repository_location) |
| 168 | |
| 169 | def assert_no_manifest_replay(self, manifest, key): |
| 170 | try: |
| 171 | with self.manifest_ts_file.open() as fd: |
| 172 | timestamp = fd.read() |
| 173 | logger.debug("security: read manifest timestamp %r", timestamp) |
| 174 | except FileNotFoundError: |
| 175 | logger.debug("security: manifest timestamp file %s not found", self.manifest_ts_file) |
| 176 | timestamp = "" |
| 177 | except OSError as exc: |
| 178 | logger.warning("Could not read previous location file: %s", exc) |
| 179 | timestamp = "" |
| 180 | logger.debug("security: determined newest manifest timestamp as %s", timestamp) |
| 181 | # If repository is older than the cache or security dir something fishy is going on |
| 182 | if timestamp and timestamp > manifest.timestamp: |
| 183 | if isinstance(key, PlaintextKey): |
| 184 | raise Cache.RepositoryIDNotUnique() |
| 185 | else: |
| 186 | raise Cache.RepositoryReplay() |
| 187 | |
| 188 | def assert_key_type(self, key): |
| 189 | # Make sure an encrypted repository has not been swapped for an unencrypted repository |
no test coverage detected