saltstack / saltstack/salt

[BUG] CSF state Module Ignore test=true

Open
#57,656 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-medium State-Module
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

csf State Module ignore the parameter test=true on execution

state ID example

csf_open_ports_tcp_out:
  csf.ports_open:
    - ports: {{ pillar.csf_ports.tcp.out }}
    - proto: tcp
    - direction: out

State execution example :

salt test-minion state.apply csf.ports test=true

The execution will apply all change regardless of the test=true parameter


test-minion:
----------
          ID: csf_open_ports_tcp_in
    Function: csf.ports_open
      Result: True
     Comment: --- 
              +++ 
              @@ -136,7 +136,7 @@
               LF_SPI = "1"
               
               # Allow incoming TCP ports
              -TCP_IN = "80,443,5060,8090,20000,20001,30001:30017"
              +TCP_IN = "80,443,5060,20000,20001,30001:30017"
               
               # Allow outgoing TCP ports
               TCP_OUT = "25,43,53,80,443,8443,44445"
     Started: 08:46:16.238621
    Duration: 6091.478 ms
     Changes:   
              ----------
              Ports:
                  Changed
----------
          ID: csf_open_ports_tcp_out
    Function: csf.ports_open
      Result: True
     Comment: unless condition is true
     Started: 08:46:22.330314
    Duration: 23.036 ms
     Changes:   
----------
          ID: csf_open_ports_udp_in
    Function: csf.ports_open
      Result: True
     Comment: unless condition is true
     Started: 08:46:22.353602
    Duration: 19.851 ms
     Changes:   
----------
          ID: csf_open_ports_udp_out
    Function: csf.ports_open
      Result: True
     Comment: Ports open.
     Started: 08:46:22.373704
    Duration: 27.082 ms
     Changes:   

Summary for test-centos81
------------
Succeeded: 4 (changed=1)
Failed:    0
------------
Total states run:     4
Total run time:   6.161 s

Expected behavior
if test=truethe changes should never be applied

Succeeded: 4 (Unchanged 1, changed=1)

Salt Version:
           Salt: 3000.3
 
Dependency Versions:
           cffi: 1.12.3
       cherrypy: unknown
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.11.1
        libgit2: 0.28.2
       M2Crypto: 0.35.2
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.28.2
         Python: 3.6.8 (default, Apr  2 2020, 13:34:55)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 15.3.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.4
 
System Versions:
           dist: centos 7.8.2003 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-1127.8.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.8.2003 Core
 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the csf.ports_open state module from the state.apply execution path and inspect how it handles test=true. Reproduce the example on a test minion, then add coverage showing that test=true reports changes without applying them and verify that normal execution still applies changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.