Project

General

Profile

Actions

Bug #19199

closed

Techniques using a condition containing a variable are not canonified correctly with dsc agent

Bug #19199: Techniques using a condition containing a variable are not canonified correctly with dsc agent

Added by Félix DALLIDET over 4 years ago. Updated over 4 years ago.

Status:
Released
Priority:
N/A
Category:
Web - Technique editor
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
To do
Fix check:
Checked
Regression:

Description

When creating a technique, if you use a condition based on a variable content, it will not canonify its value, leading to malformed conditions.
The logic should already be written since on the CfEngine technique side it is properly canonified.

We currently generate something like:

function Test-Technique {
  [CmdletBinding()]
  param (
      [parameter(Mandatory=$true)]
      [string]$reportId,
      [parameter(Mandatory=$true)]
      [string]$techniqueName,
      [parameter(Mandatory=$true)]
      [string]$File,
      [switch]$auditOnly
  )

  $local_classes = New-ClassContext
  $resources_dir = $PSScriptRoot + "\resources" 

  $local_classes = Merge-ClassContext $local_classes $(File-Content -File "${file}" -Lines "my_content" -Enforce "true" -componentName "File content" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")

  $class = "any.(file_lines_present_${file}_repaired)" 
  if (Evaluate-Class $class $local_classes $system_classes) {
    $local_classes = Merge-ClassContext $local_classes $(File-Content -File "C:\result.txt" -Lines "un peu de contenu
sur
plusieurs lignes" -Enforce "true" -componentName "File content" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")
  } else {
    _rudder_common_report_na -componentName "File content" -componentKey "C:\result.txt" -message "Not applicable" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly
  }

}

And we want something like:

function Test-Technique {
  [CmdletBinding()]
  param (
      [parameter(Mandatory=$true)]
      [string]$reportId,
      [parameter(Mandatory=$true)]
      [string]$techniqueName,
      [parameter(Mandatory=$true)]
      [string]$File,
      [switch]$auditOnly
  )

  $local_classes = New-ClassContext
  $resources_dir = $PSScriptRoot + "\resources" 

  $local_classes = Merge-ClassContext $local_classes $(File-Content -File "${file}" -Lines "my_content" -Enforce "true" -componentName "File content" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")

  $class = "any.(file_lines_present_" + $(Canonify-Class $file) + "_repaired)" 
  if (Evaluate-Class $class $local_classes $system_classes) {
    $local_classes = Merge-ClassContext $local_classes $(File-Content -File "C:\result.txt" -Lines "un peu de contenu
sur
plusieurs lignes" -Enforce "true" -componentName "File content" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly).get_item("classes")
  } else {
    _rudder_common_report_na -componentName "File content" -componentKey "C:\result.txt" -message "Not applicable" -reportId $reportId -techniqueName $techniqueName -auditOnly:$auditOnly
  }

}

The diff is on the lines:

$class = "any.(file_lines_present_${file}_repaired)" 

and

$class = "any.(file_lines_present_" + $(Canonify-Class $file) + "_repaired)" 

Updated by Vincent MEMBRÉ over 4 years ago Actions #1

  • Project changed from 78 to Rudder
  • Subject changed from Conditions containing a variable are not properly canonified to Conditions containing a variable are not canonfied with dsc agnt
  • Category changed from Generic methods to Web - Technique editor
  • Target version changed from 6.1-1.22 to 6.1.13

Updated by Vincent MEMBRÉ over 4 years ago Actions #2

  • Status changed from New to In progress

Updated by Vincent MEMBRÉ over 4 years ago Actions #3

  • Assignee changed from Vincent MEMBRÉ to François ARMAND
  • Pull Request set to https://github.com/Normation/rudder/pull/3608

Updated by Vincent MEMBRÉ over 4 years ago Actions #4

  • Status changed from In progress to Pending technical review

Updated by Vincent MEMBRÉ over 4 years ago Actions #5

  • Subject changed from Conditions containing a variable are not canonfied with dsc agnt to Techniques using a condition containing a variable are not canonified correctly with dsc agent

Updated by Vincent MEMBRÉ over 4 years ago Actions #6

  • Status changed from Pending technical review to Pending release

Updated by Benoît PECCATTE over 4 years ago Actions #7

  • Fix check changed from To do to Checked

Updated by Vincent MEMBRÉ over 4 years ago Actions #8

  • Status changed from Pending release to Released

This bug has been fixed in Rudder 6.1.13 and 6.2.7 which were released today.

Actions

Also available in: PDF Atom