#49948 Issue 49947 - Coverity: 389-ds-base-1.4.0.16.20180905git8ff8cb8
Closed 3 years ago by spichugi. Opened 5 years ago by mhonek.
mhonek/389-ds-base covfix-2018-09-05  into  master

@@ -246,7 +246,7 @@ 

                  'password123', 'does not contain minimum number of alphas')

      # Max Repeats

      tryPassword(topology_st.standalone, 'passwordMaxRepeats', 2, 0, 'passsword',

-                 'pasword123', 'too many repeating characters')

+                 'password123', 'too many repeating characters')

      # Min Specials

      tryPassword(topology_st.standalone, 'passwordMinSpecials', 2, 0, 'passwd',

                  'password_#$',

file modified
+1 -1
@@ -1221,7 +1221,7 @@ 

                  syntax_violation = 1;

                  PR_snprintf(errormsg, sizeof(errormsg) - 1,

                              "invalid password syntax - a character cannot be repeated more than %d times",

-                             (pwpolicy->pw_maxrepeats + 1));

+                             (pwpolicy->pw_maxrepeats));

              } else if (pwpolicy->pw_mincategories > num_categories) {

                  syntax_violation = 1;

                  PR_snprintf(errormsg, sizeof(errormsg) - 1,

file removed
-107
@@ -1,107 +0,0 @@ 

- # --- BEGIN COPYRIGHT BLOCK ---

- # Copyright (C) 2015 Red Hat, Inc.

- # All rights reserved.

- #

- # License: GPL (version 3 or any later version).

- # See LICENSE for details.

- # --- END COPYRIGHT BLOCK ---

- 

- from bug_harness import DSAdminHarness as DSAdmin

- from dsadmin.tools import DSAdminTools

- from lib389.properties import *

- """

-     An harness for bug replication.

- 

- """

- import os

- 

- REPLBINDDN = ''

- REPLBINDPW = ''

- 

- 

- @static_var("REPLICAID", 1)

- def get_next_replicaid(replica_id=None, replica_type=None):

-     if replica_id:

-         REPLICAID = replica_id

-         return REPLICAID

-     # get a default replica_id if it's a MASTER,

-     # or 0 if consumer

-     if replica_type == MASTER_TYPE:

-         REPLICAID += 1

-         return REPLICAID

- 

-     return 0

- 

- 

- class DSAdminHarness(DSAdmin, DSAdminTools):

-     """Harness wrapper around dsadmin.

- 

-        Specialize the DSAdmin behavior (No, I don't care about Liskov ;))

-     """

-     def setupSSL(self, secport, sourcedir=os.environ['SECDIR'], secargs=None):

-         """Bug scripts requires SECDIR."""

-         return DSAdminTools.setupSSL(self, secport, sourcedir, secargs)

- 

-     def setupAgreement(self, repoth, args):

-         """Set default replia credentials """

-         args.setdefault('binddn', REPLBINDDN)

-         args.setdefault('bindpw', REPLBINDPW)

- 

-         return DSAdmin.createAgreement(self, repoth, args)

- 

-     def setupReplica(self, args):

-         """Set default replia credentials """

-         args.setdefault('binddn', REPLBINDDN)

-         args.setdefault('bindpw', REPLBINDPW)

-         # manage a progressive REPLICAID

-         args.setdefault(

-             'id', get_next_replicaid(args.get('id'), args.get('type')))

-         return DSAdmin.setupReplica(self, args)

- 

-     def setupBindDN(self, binddn=REPLBINDDN, bindpw=REPLBINDPW):

-         return DSAdmin.setupBindDN(self, binddn, bindpw)

- 

-     def setupReplBindDN(self, binddn=REPLBINDDN, bindpw=REPLBINDPW):

-         return self.setupBindDN(binddn, bindpw)

- 

-     def setupBackend(self, suffix, binddn=None, bindpw=None, urls=None,

-                      attrvals=None, benamebase=None, verbose=False):

-         """Create a backends using the first available cn."""

-         # if benamebase is set, try creating without appending

-         if benamebase:

-             benum = 0

-         else:

-             benum = 1

- 

-         # figure out what type of be based on args

-         if binddn and bindpw and urls:  # its a chaining be

-             benamebase = benamebase or "chaindb"

-         else:  # its a ldbm be

-             benamebase = benamebase or "localdb"

- 

-         done = False

-         while not done:

-             # if benamebase is set, benum starts at 0

-             # and the first attempt tries to create the

-             # simple benamebase. On failure benum is

-             # incremented and the suffix is appended

-             # to the cn

-             if benum:

-                 benamebase_tmp = benamebase + str(benum)  # e.g. localdb1

-             else:

-                 benamebase_tmp = benamebase

- 

-             try:

-                 cn = DSAdmin.setupBackend(suffix, binddn, bindpw,

-                                           urls, attrvals, benamebase, verbose)

-                 done = True

-             except ldap.ALREADY_EXISTS:

-                 benum += 1

- 

-         return cn

- 

-     def createInstance(args):

-         # eventually set prefix

-         args.setdefault(SER_DEPLOYED_DIR, os.environ.get('PREFIX', None))

-         args.setdefault('sroot', os.environ.get('SERVER_ROOT', None))

-         DSAdminTools.createInstance(args)

@@ -16,16 +16,6 @@ 

  from lib389.utils import assert_c, get_ldapurl_from_serverid

  from lib389.properties import *

  

- MAJOR, MINOR, _, _, _ = sys.version_info

- 

- 

- # REALLY PYTHON 3? REALLY???

- def _input(msg):

-     if MAJOR >= 3:

-         return input(msg)

-     else:

-         return input(msg)

- 

  

  def _get_arg(args, msg=None, hidden=False, confirm=False):

      if args is not None and len(args) > 0:
@@ -43,7 +33,7 @@ 

              else:

                  return getpass("%s : " % msg)

          else:

-             return _input("%s : " % msg)

+             return input("%s : " % msg)

  

  

  def _get_args(args, kws):
@@ -57,7 +47,7 @@ 

              if priv:

                  kwargs[kw] = getpass("%s : " % msg)

              else:

-                 kwargs[kw] = _input("%s : " % msg)

+                 kwargs[kw] = input("%s : " % msg)

      return kwargs

  

  
@@ -76,7 +66,7 @@ 

                  kwargs[attr] = getpass("Enter value for %s : " % attr)

              else:

                  attr_normal = attr.lower()

-                 kwargs[attr_normal] = _input("Enter value for %s : " % attr)

+                 kwargs[attr_normal] = input("Enter value for %s : " % attr)

  

      return kwargs

  
@@ -84,7 +74,7 @@ 

  def _warn(data, msg=None):

      if msg is not None:

          print("%s :" % msg)

-     if 'Yes I am sure' != _input("Type 'Yes I am sure' to continue: "):

+     if 'Yes I am sure' != input("Type 'Yes I am sure' to continue: "):

          raise Exception("Not sure if want")

      return data

  

@@ -87,7 +87,7 @@ 

      log.debug("dsrc path: %s" % path)

      # First read our config

      # No such file?

-     config = configparser.SafeConfigParser()

+     config = configparser.ConfigParser()

      config.read([path])

  

      log.debug("dsrc instances: %s" % config.sections())

@@ -442,7 +442,7 @@ 

              return False

          config = None

          try:

-             config = configparser.SafeConfigParser()

+             config = configparser.ConfigParser()

              config.read([inf_path])

          except Exception as e:

              self.log.error("Exception %s occured", e)

file modified
+1 -1
@@ -128,7 +128,7 @@ 

  

      def _read_defaults(self):

          spath = self._get_defaults_loc(DEFAULTS_PATH)

-         self._config = configparser.SafeConfigParser()

+         self._config = configparser.ConfigParser()

          self._config.read([spath])

          self._defaults_cached = True

  

@@ -86,8 +86,6 @@ 

          else:

              return None

  

-         raise NotImplemented

- 

      def setProperties(self, suffix):

          '''

              Supported properties:

@@ -108,20 +108,20 @@ 

      # In the new api this becomes a get over the selector type

      # In the case this fails, this actually throws exception

      ent = topology.standalone.backends.get(NEW_SUFFIX_1)

+     assert ent is not None

      topology.standalone.log.info("List suffix (%d): backend %s" %

                                   (1, ent.dn))

-     assert ent is not None

  

      log.info("Check list a backend by its name")

      ent = topology.standalone.backends.get(NEW_BACKEND_2)

+     assert ent is not None

      topology.standalone.log.info("List name (%d): backend %s" %

                                   (1, ent.dn))

-     assert ent is not None

  

      log.info("Check get backends by their DN")

      ents = topology.standalone.backends.get(dn=ent.dn)

-     topology.standalone.log.info("List DN (%d): backend %s" % (1, ents.dn))

      assert ents is not None

+     topology.standalone.log.info("List DN (%d): backend %s" % (1, ents.dn))

  

      # The new backends api just does selection on a single attr, and

      # You would then validate the other attributes on retrival.

@@ -179,18 +179,18 @@ 

  

      log.info("Try to get a backend with backend suffix")

      d1 = backends.get(NEW_SUFFIX_1_RDN)

-     topology_st.standalone.log.info("Suffix (%d): backend %s" % (1, d1.dn))

      assert d1 is not None

+     topology_st.standalone.log.info("Suffix (%d): backend %s" % (1, d1.dn))

  

      log.info("Try to get a backend with backend name")

      d2 = backends.get(BACKEND_NAME_1)

-     topology_st.standalone.log.info("Backend (%d): backend (%s)" % (1, d2.dn))

      assert d2 is not None

+     topology_st.standalone.log.info("Backend (%d): backend %s" % (1, d2.dn))

  

      log.info("Try to get a backend with backend DN")

      d3 = backends.get(dn=backend.dn)

-     topology_st.standalone.log.info("DN (%d): backend %s" % (1, d3.dn))

      assert d3 is not None

+     topology_st.standalone.log.info("DN (%d): backend %s" % (1, d3.dn))

  

  

  def test_get_invalid(topology_st, backend):

@@ -54,17 +54,6 @@ 

  MAJOR, MINOR, _, _, _ = sys.version_info

  

  log = logging.getLogger(__name__)

- #

- # Decorator

- #

- 

- 

- def static_var(varname, value):

-     def decorate(func):

-         setattr(func, varname, value)

-         return func

-     return decorate

- 

  

  #

  # Various searches to be used in getEntry

Bugs and fixes description:
- 15607:
- in lib389/suffix.py: Structurally dead code
- 15604:
- in bug_harness.py: Null dereference
+ solved by removing the file as it is unused and outdated
- additionally, remove the static_var decorator definition as it
is not used anyway any more
- 15754:
- in pwdPolicy_syntax_test.py: fix typo in identifier
+ Fix log msg in file pw.c
- 17046, 17061, 17063, 17069, 17084:
- in backend_test and backendLegacy_test: fix use before NULL check
- 17473:
- in lib389/init.py: Identical code in different branches
+ removed the wrapper altogether as we don't support Python2 any more
- replace SafeConfigParser with ConfigParser for it has been just an
alias since Python 3.2 and will be removed in the future

https://pagure.io/389-ds-base/issue/49947

Author: mhonek

Review by: ???

Hey there,

What does this bug_harness file do? What's it's purpose? Thanks :)

The code looks good to me! The tests pass. You have my ack.

https://pagure.io/fork/mhonek/389-ds-base/blob/ba61344679a7df26e3f1b14bcd218bfe6f5f9592/f/src/lib389/bug_harness.py
It is a harness wrapper around DSAdmin tools which we don't have.
I agree with Matus, there is no point in keeping it.

@firstyear Sorry I've not responded (and glad Simon did). I'm genuinely missing a notification about your comment in my mail client. :(

rebased onto 6030eaa150de706437ade5299a2880cf6830f7ea

5 years ago

rebased onto 4f118f4

5 years ago

Pull-Request has been merged by mhonek

5 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3007

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago