Security hardening, multi-site portability, and a documentation and API-surface sweep
This commit is contained in:
@@ -20,6 +20,7 @@ from typing import Dict, List, Optional, Type
|
||||
from flask import Flask, Blueprint
|
||||
|
||||
from shopdb.plugins.base import BasePlugin, PluginMeta
|
||||
from shopdb.api import Setting
|
||||
|
||||
from .api import backups_bp
|
||||
from .models import BackupRevision
|
||||
@@ -165,7 +166,10 @@ class BackupsPlugin(BasePlugin):
|
||||
'valuetype': 'string',
|
||||
'category': 'backups',
|
||||
'description': 'UNC root that opaque (non-JSON) backups are '
|
||||
'written under by the collecting PC. Site-specific.',
|
||||
'written under by the collecting PC, e.g. '
|
||||
'\\\\fileserver\\shopfloor\\backups. Blank until '
|
||||
'the site sets it: no default can be right at '
|
||||
'more than one site (ADR-015).',
|
||||
},
|
||||
{
|
||||
'key': 'backups_staledays',
|
||||
@@ -395,8 +399,14 @@ class BackupsPlugin(BasePlugin):
|
||||
|
||||
pruned = prune(
|
||||
assetid, kindkey,
|
||||
retentioncount=self.get_setting('backups_retentioncount', 0),
|
||||
retentiondays=self.get_setting('backups_retentiondays', 0),
|
||||
# Setting.get, NOT self.get_setting. The BasePlugin helper
|
||||
# namespaces what it reads to `plugin.backups.<key>`, while
|
||||
# get_settings_defaults declares - and the settings page writes -
|
||||
# the bare key. So this read never found the value an operator had
|
||||
# set, always fell back to 0, and 0 means "keep everything": the
|
||||
# retention policy was configurable in the UI and did nothing.
|
||||
retentioncount=Setting.get('backups_retentioncount', 0),
|
||||
retentiondays=Setting.get('backups_retentiondays', 0),
|
||||
)
|
||||
if pruned:
|
||||
warnings.append('pruned {} old revision(s) per retention policy'
|
||||
|
||||
Reference in New Issue
Block a user