Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2743

Classesmatching uses anchored regex in contradiction to its documentation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 3.7.3, 3.10.2
    • Fix Version/s: 3.12.0, 3.10.3, 3.7.7
    • Component/s: Documentation
    • Labels:
      None
    • Environment:
      CentOS 6

      Description

      According to the documentation for the classesmatching() function, the "name" regex to be matched against is an unanchored regex.

      This surprised me since CFEngine uses anchored regexes pretty much everywhere else.

      Sure enough, the documentation is wrong (or the code is wrong, depending on your point of view):

      [root@localhost ~]# cf-agent -V
      CFEngine Core 3.10.2
      CFEngine Enterprise 3.10.2
      [root@localhost ~]# cat classes.cf
      bundle agent main {
        vars:
          "some_var"
            slist => classesmatching("tos");
        reports:
          "$(some_var)";
      }
      [root@localhost ~]# cf-agent -KIC -f ./classes.cf 
      [root@localhost ~]# cat classes2.cf 
      bundle agent main {
        vars:
          "some_var"
            slist => classesmatching(".*tos.*");
        reports:
          "$(some_var)";
      }
      [root@localhost ~]# cf-agent -KIC -f ./classes2.cf 
      R: centos_6
      R: centos
      R: centos_6_6
      [root@localhost ~]# 
      

      This is a bug (either in the code or in the documentation).

      Please note that according to Promise Theory, the documentation is the publication of the developers' intentions to the users of CFEngine. Also according to Promise Theory, when the published intention to the promisee does not match the observed behavior of the promiser, the result is reduced trust in that promiser by that promisee. So having the documentation inaccurate as a description of the behavior of CFEngine is a promise not kept by the developers and is factually more important to avoid than I believe is currently recognized!

        Attachments

          Activity

            People

            • Assignee:
              a10042 Nick Anderson
              Reporter:
              mweilgart Mike Weilgart
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel