def downgrade():
    """Downgrade database schema and/or data back to the previous revision."""
    for object_type, roles_tree \
            in product_group_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION.items():
        if "ProductGroup" in object_type:
            acr_propagation.remove_propagated_roles(object_type,
                                                    roles_tree.keys())
def downgrade():
    """Remove Risk propagated roles"""
    for object_type, roles_tree in const.WORKFLOW_PROPAGATION.items():
        acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())

    op.bulk_insert(acr_propagation.ACR_TABLE,
                   [{
                       'name': 'Admin Mapped',
                       'object_type': 'Workflow',
                       'tooltip': None,
                       'read': True,
                       'update': True,
                       'delete': True,
                       'my_work': False,
                       'mandatory': False,
                       'non_editable': True,
                       'internal': True,
                       'created_at': datetime.datetime.now(),
                       'updated_at': datetime.datetime.now(),
                       'default_to_current_user': False,
                   }, {
                       'name': 'Workflow Member Mapped',
                       'object_type': 'Workflow',
                       'tooltip': None,
                       'read': True,
                       'update': False,
                       'delete': False,
                       'my_work': False,
                       'mandatory': False,
                       'non_editable': True,
                       'internal': True,
                       'created_at': datetime.datetime.now(),
                       'updated_at': datetime.datetime.now(),
                       'default_to_current_user': False,
                   }])
Exemplo n.º 3
0
def downgrade():
    """Downgrade database schema and/or data back to the previous revision."""

    connection = op.get_bind()
    ids = connection.execute("""
      select
        acl.id,
        acl.object_type,
        acl.object_id,
        p.email,
        acr.name
      from acl_copy as acl
      left join people as p on
        acl.person_id = p.id
      left join access_control_roles as acr on
        acl.ac_role_id = acr.id
      where
        acl.parent_id is null and
        acl.id not in (select id from access_control_list)
  """).fetchall()
    print "ACL entries that will be reintroduced by this downgrade:"
    for row in ids:
        print row

    ids = connection.execute("""
      select
        acl.id,
        acl.object_type,
        acl.object_id,
        p.email,
        acr.name
      from access_control_list as acl
      left join people as p on
        acl.person_id = p.id
      left join access_control_roles as acr on
        acl.ac_role_id = acr.id
      where
        acl.parent_id is null and
        acl.id not in (select id from acl_copy)
  """).fetchall()
    print "ACL entries that will not be propagated properly by this downgrade:"
    print "To fix these roles please manually remove and re-add them."
    for row in ids:
        print row

    for object_type, roles_tree in const.GGRC_PROPAGATION.items():
        acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
    _remove_parent_id_column()

    op.execute(
        "INSERT IGNORE INTO access_control_roles SELECT * from acr_copy")
    op.execute("INSERT IGNORE INTO access_control_list SELECT * from acl_copy")
Exemplo n.º 4
0
def downgrade():
  """Downgrade database schema and/or data back to the previous revision."""

  connection = op.get_bind()
  ids = connection.execute("""
      select
        acl.id,
        acl.object_type,
        acl.object_id,
        p.email,
        acr.name
      from acl_copy as acl
      left join people as p on
        acl.person_id = p.id
      left join access_control_roles as acr on
        acl.ac_role_id = acr.id
      where
        acl.parent_id is null and
        acl.id not in (select id from access_control_list)
  """).fetchall()
  print "ACL entries that will be reintroduced by this downgrade:"
  for row in ids:
    print row

  ids = connection.execute("""
      select
        acl.id,
        acl.object_type,
        acl.object_id,
        p.email,
        acr.name
      from access_control_list as acl
      left join people as p on
        acl.person_id = p.id
      left join access_control_roles as acr on
        acl.ac_role_id = acr.id
      where
        acl.parent_id is null and
        acl.id not in (select id from acl_copy)
  """).fetchall()
  print "ACL entries that will not be propagated properly by this downgrade:"
  print "To fix these roles please manually remove and re-add them."
  for row in ids:
    print row

  for object_type, roles_tree in const.GGRC_PROPAGATION.items():
    acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
  _remove_parent_id_column()

  op.execute("INSERT IGNORE INTO access_control_roles SELECT * from acr_copy")
  op.execute("INSERT IGNORE INTO access_control_list SELECT * from acl_copy")
Exemplo n.º 5
0
def downgrade():
  """Downgrade database schema and/or data back to the previous revision."""
  op.drop_table('technology_environments')

  for object_type, roles_tree in tech_env_rules.GGRC_PROPAGATION.items():
    if "TechnologyEnvironment" in object_type:
      acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())

  # Remove items from access_control_list
  op.execute("DELETE FROM access_control_list "
             "WHERE object_type = 'TechnologyEnvironment'")
  # Remove items from access_control_roles
  op.execute("DELETE FROM access_control_roles "
             "WHERE object_type = 'TechnologyEnvironment'")
Exemplo n.º 6
0
def downgrade():
    """Downgrade database schema and/or data back to the previous revision."""
    op.drop_table('product_groups')

    for object_type, roles_tree in product_group_rules.GGRC_PROPAGATION.items(
    ):
        if "ProductGroup" in object_type:
            acr_propagation.remove_propagated_roles(object_type,
                                                    roles_tree.keys())

    # Remove items from access_control_list
    op.execute("DELETE FROM access_control_list "
               "WHERE object_type = 'ProductGroup'")
    # Remove items from access_control_roles
    op.execute("DELETE FROM access_control_roles "
               "WHERE object_type = 'ProductGroup'")
def downgrade():
  """Remove Risk propagated roles"""
  for object_type, roles_tree in const.WORKFLOW_PROPAGATION.items():
    acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())

  op.bulk_insert(
      acr_propagation.ACR_TABLE,
      [{
          'name': 'Admin Mapped',
          'object_type': 'Workflow',
          'tooltip': None,
          'read': True,
          'update': True,
          'delete': True,
          'my_work': False,
          'mandatory': False,
          'non_editable': True,
          'internal': True,
          'created_at': datetime.datetime.now(),
          'updated_at': datetime.datetime.now(),
          'default_to_current_user': False,
      }, {
          'name': 'Workflow Member Mapped',
          'object_type': 'Workflow',
          'tooltip': None,
          'read': True,
          'update': False,
          'delete': False,
          'my_work': False,
          'mandatory': False,
          'non_editable': True,
          'internal': True,
          'created_at': datetime.datetime.now(),
          'updated_at': datetime.datetime.now(),
          'default_to_current_user': False,
      }]
  )
Exemplo n.º 8
0
def downgrade():
  """Remove Risk propagated roles"""
  for object_type, roles_tree in const.GGRC_RISKS_PROPAGATION.items():
    acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
def remove_old_rule_tree():
    """Remove old ACL propagation rules"""
    propagation = prev_rules.GGRC_PROPAGATION
    for object_type, roles_tree in propagation.items():
        acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
def downgrade():
    """Downgrade database schema and/or data back to the previous revision."""
    propagation = const.GGRC_BASIC_PERMISSIONS_PROPAGATION
    for object_type, roles_tree in propagation.items():
        acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
Exemplo n.º 11
0
def downgrade():
    """Remove Risk propagated roles"""
    for object_type, roles_tree in const.GGRC_RISKS_PROPAGATION.items():
        acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
Exemplo n.º 12
0
def downgrade():
  """Downgrade database schema and/or data back to the previous revision."""
  propagation = const.GGRC_BASIC_PERMISSIONS_PROPAGATION
  for object_type, roles_tree in propagation.items():
    acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
Exemplo n.º 13
0
def remove_old_rule_tree():
  """Remove old ACL propagation rules"""
  propagation = prev_rules.GGRC_PROPAGATION
  for object_type, roles_tree in propagation.items():
    acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
Exemplo n.º 14
0
def downgrade():
  """Downgrade database schema and/or data back to the previous revision."""
  for object_type, roles_tree in \
          scoping_objects_rules.GGRC_PROPAGATION.items():
    acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())
def downgrade():
  """Downgrade database schema and/or data back to the previous revision."""
  for object_type, roles_tree \
          in tech_env_rules.GGRC_BASIC_PERMISSIONS_PROPAGATION.items():
    if "TechnologyEnvironment" in object_type:
      acr_propagation.remove_propagated_roles(object_type, roles_tree.keys())