Safety Valve Override

- Support 'allow.empty.filter', defaulting to 'yes', but if 'no' disallows the
  combination of a write command and an empty filter.  Ordinarily this is just
  a warning that requires confirmation (thanks to Lee Lieske).
This commit is contained in:
Paul Beckingham 2014-08-11 12:32:11 -04:00
parent c2ffee1352
commit 1ccc284cc7
12 changed files with 23 additions and 0 deletions

View file

@ -225,3 +225,4 @@ suggestions:
Kevin Ballard Kevin Ballard
Sitaram Chamarty Sitaram Chamarty
lolilolicon lolilolicon
Lee Lieske

View file

@ -166,6 +166,9 @@
Richard Boß). Richard Boß).
- Fixed typo in 'newest' and 'oldest' report definitions (thanks to Richard Boß). - Fixed typo in 'newest' and 'oldest' report definitions (thanks to Richard Boß).
- The 'diagnostics' command obeys color settings. - The 'diagnostics' command obeys color settings.
- Support 'allow.empty.filter', defaulting to 'yes', but if 'no' disallows the
combination of a write command and an empty filter. Ordinarily this is just a
warning that requires confirmation (thanks to Lee Lieske).
------ current release --------------------------- ------ current release ---------------------------

2
NEWS
View file

@ -29,6 +29,8 @@ New configuration options in taskwarrior 2.4.0
- The 'taskd.trust' setting is now a tri-state, supporting values 'strict', - The 'taskd.trust' setting is now a tri-state, supporting values 'strict',
'ignore hostname' and 'allow all', for server certificate validation. 'ignore hostname' and 'allow all', for server certificate validation.
- New themes: dark-default-16.theme, dark-gray-blue-256.theme - New themes: dark-default-16.theme, dark-gray-blue-256.theme
- The 'allow.empty.filter' setting can be set to 'no' to disallow the
potentially dangerous combination of write commands and empty filters.
Newly deprecated features in taskwarrior 2.4.0 Newly deprecated features in taskwarrior 2.4.0

View file

@ -281,6 +281,13 @@ confirmation before deleting a task, performing bulk changes, or the undo
command. The default value is "yes". Consider leaving this setting as "yes", command. The default value is "yes". Consider leaving this setting as "yes",
for safety. for safety.
.TP
.B allow.empty.filter=yes
An empty filter combined with a write command is potentially a way to modify
all tasks by mistkae, and when this is detected, confirmation is required.
Setting this to 'no' means that it is an error to use a write command with no
filter.
.TP .TP
.B indent.annotation=2 .B indent.annotation=2
Controls the number of spaces to indent annotations when shown beneath the Controls the number of spaces to indent annotations when shown beneath the

View file

@ -81,6 +81,7 @@ std::string Config::_defaults =
"# # Comma-separated list. May contain any subset of:\n" "# # Comma-separated list. May contain any subset of:\n"
"#verbose=blank,header,footnote,label,new-id,new-uuid,affected,edit,special,project,sync,filter\n" "#verbose=blank,header,footnote,label,new-id,new-uuid,affected,edit,special,project,sync,filter\n"
"confirmation=yes # Confirmation on delete, big changes\n" "confirmation=yes # Confirmation on delete, big changes\n"
"allow.empty.filter=yes # An empty filter gets a warning and requires confirmation\n"
"indent.annotation=2 # Indent spaces for annotations\n" "indent.annotation=2 # Indent spaces for annotations\n"
"indent.report=0 # Indent spaces for whole report\n" "indent.report=0 # Indent spaces for whole report\n"
"row.padding=0 # Left and right padding for each row of report\n" "row.padding=0 # Left and right padding for each row of report\n"

View file

@ -259,6 +259,9 @@ void Filter::safety ()
{ {
if (context.parser.getFilterExpression () == "") if (context.parser.getFilterExpression () == "")
{ {
if (! context.config.getBoolean ("allow.empty.filter"))
throw std::string (STRING_TASK_SAFETY_ALLOW);
// If user is willing to be asked, this can be avoided. // If user is willing to be asked, this can be avoided.
if (context.config.getBoolean ("confirmation") && if (context.config.getBoolean ("confirmation") &&
confirm (STRING_TASK_SAFETY_VALVE)) confirm (STRING_TASK_SAFETY_VALVE))

View file

@ -69,6 +69,7 @@ int CmdShow::execute (std::string& output)
std::string recognized = std::string recognized =
" abbreviation.minimum" " abbreviation.minimum"
" active.indicator" " active.indicator"
" allow.empty.filter"
" avoidlastcolumn" " avoidlastcolumn"
" bulk" " bulk"
" burndown.bias" " burndown.bias"

View file

@ -842,6 +842,7 @@
#define STRING_TASK_VALID_PRIORITY "Priority values may be 'H', 'M' or 'L', not '{1}'." #define STRING_TASK_VALID_PRIORITY "Priority values may be 'H', 'M' or 'L', not '{1}'."
#define STRING_TASK_SAFETY_VALVE "This command has no filter, and will modify all tasks. Are you sure?" #define STRING_TASK_SAFETY_VALVE "This command has no filter, and will modify all tasks. Are you sure?"
#define STRING_TASK_SAFETY_FAIL "Command prevented from running." #define STRING_TASK_SAFETY_FAIL "Command prevented from running."
#define STRING_TASK_SAFETY_ALLOW "You did not specify a filter, and with the 'allow.empty.filter' value, no action is taken."
// TDB2 // TDB2
#define STRING_TDB2_PARSE_ERROR " in {1} at line {2}" #define STRING_TDB2_PARSE_ERROR " in {1} at line {2}"

View file

@ -854,6 +854,7 @@
#define STRING_TASK_VALID_PRIORITY "Valores de prioridad pueden ser 'H', 'M' o 'L', no '{1}'." #define STRING_TASK_VALID_PRIORITY "Valores de prioridad pueden ser 'H', 'M' o 'L', no '{1}'."
#define STRING_TASK_SAFETY_VALVE "Este comando no tiene filtro, y modificará todas las tareas. ¿Está seguro?" #define STRING_TASK_SAFETY_VALVE "Este comando no tiene filtro, y modificará todas las tareas. ¿Está seguro?"
#define STRING_TASK_SAFETY_FAIL "Se impidió la ejecución del comando." #define STRING_TASK_SAFETY_FAIL "Se impidió la ejecución del comando."
#define STRING_TASK_SAFETY_ALLOW "You did not specify a filter, and with the 'allow.empty.filter' value, no action is taken."
// TDB2 // TDB2
#define STRING_TDB2_PARSE_ERROR " en {1} en la línea {2}" #define STRING_TDB2_PARSE_ERROR " en {1} en la línea {2}"

View file

@ -841,6 +841,7 @@
#define STRING_TASK_VALID_PRIORITY "Priority values may be 'H', 'M' or 'L', not '{1}'." #define STRING_TASK_VALID_PRIORITY "Priority values may be 'H', 'M' or 'L', not '{1}'."
#define STRING_TASK_SAFETY_VALVE "This command has no filter, and will modify all tasks. Are you sure?" #define STRING_TASK_SAFETY_VALVE "This command has no filter, and will modify all tasks. Are you sure?"
#define STRING_TASK_SAFETY_FAIL "Command prevented from running." #define STRING_TASK_SAFETY_FAIL "Command prevented from running."
#define STRING_TASK_SAFETY_ALLOW "You did not specify a filter, and with the 'allow.empty.filter' value, no action is taken."
// TDB2 // TDB2
#define STRING_TDB2_PARSE_ERROR " in {1} at line {2}" #define STRING_TDB2_PARSE_ERROR " in {1} at line {2}"

View file

@ -842,6 +842,7 @@
#define STRING_TASK_VALID_PRIORITY "I valori di priorità possono essere 'H', 'M' o 'L', non '{1}'." #define STRING_TASK_VALID_PRIORITY "I valori di priorità possono essere 'H', 'M' o 'L', non '{1}'."
#define STRING_TASK_SAFETY_VALVE "Questo comando non ha filtro, e modificherà tutti i task. Sicuro?" #define STRING_TASK_SAFETY_VALVE "Questo comando non ha filtro, e modificherà tutti i task. Sicuro?"
#define STRING_TASK_SAFETY_FAIL "Prevenuta l'esecuzione del comando." #define STRING_TASK_SAFETY_FAIL "Prevenuta l'esecuzione del comando."
#define STRING_TASK_SAFETY_ALLOW "You did not specify a filter, and with the 'allow.empty.filter' value, no action is taken."
// TDB2 // TDB2
#define STRING_TDB2_PARSE_ERROR " in {1} alla linea {2}" #define STRING_TDB2_PARSE_ERROR " in {1} alla linea {2}"

View file

@ -842,6 +842,7 @@
#define STRING_TASK_VALID_PRIORITY "Valores de prioridade podem ser 'A', 'M' ou 'B', não '{1}'." #define STRING_TASK_VALID_PRIORITY "Valores de prioridade podem ser 'A', 'M' ou 'B', não '{1}'."
#define STRING_TASK_SAFETY_VALVE "Este comando não possui um filtro e irá modificar todas as tarefas. Tem a certeza?" #define STRING_TASK_SAFETY_VALVE "Este comando não possui um filtro e irá modificar todas as tarefas. Tem a certeza?"
#define STRING_TASK_SAFETY_FAIL "Execução do comando abortada." #define STRING_TASK_SAFETY_FAIL "Execução do comando abortada."
#define STRING_TASK_SAFETY_ALLOW "You did not specify a filter, and with the 'allow.empty.filter' value, no action is taken."
// TDB2 // TDB2
#define STRING_TDB2_PARSE_ERROR " em {1} na linha {2}" #define STRING_TDB2_PARSE_ERROR " em {1} na linha {2}"