saltstack / saltstack/salt

Windows firewall state can fail while returning True

Open
#53,618 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue severity-high Windows
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

In some situations the win_firewall.add_rule state can return True after actually failing.

Setup

I created a test state sls file called firewall_fail.sls. It's contents is as follows:

Open firewall rdp port:
    win_firewall.add_rule:
       - name: RDP_test (3389)
       - localport: 3389
       - protocol: any
       - action: allow
Steps to Reproduce Issue

I ran the command:

salt win_minion state.apply firewall_fail

The output looks like this:

win_minion:
----------
          ID: Open firewall rdp port
    Function: win_firewall.add_rule
        Name: RDP_test (3389)
      Result: True
     Comment: Could not add rule
     Started: 19:55:35.018958
    Duration: 527.399 ms
     Changes:   
              ----------
              new rule:
                  RDP_test (3389)

Notice that the changes dictionary makes it look like the new rule was added, but the comment indicates what really happened (AFAICS no new rule was added). Furthermore the result was True when it should have been False.

Versions Report

The output from salt --versions-report is as follows:

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: 1.11.5
       cherrypy: Not Installed
       dateutil: 2.7.5
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.1
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.7.3 (default, May 11 2019, 00:45:16)
   python-gnupg: Not Installed
         PyYAML: 5.1
          PyZMQ: 17.0.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.6
 
System Versions:
           dist: fedora 29 Twenty Nine
         locale: UTF-8
        machine: x86_64
        release: 5.1.8-200.fc29.x86_64
         system: Linux
        version: Fedora 29 Twenty Nine

The minion that this was tested on is running salt version 2019.2.0, Python 3 64 bit.

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 at the win_firewall.add_rule entry point and reproduce the behavior with the firewall_fail.sls state using the reported salt state.apply command. Compare the returned result, comment, and changes for a failed rule creation; done means a failed firewall operation returns False and does not report a new rule as added.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.