예제 #1
0
def after_flush(session, _):
    """Handle all ACL hooks after after flush."""
    if not flask.has_app_context():
        return

    relationship.handle_relationship_creation(session)
    access_control_list.handle_acl_creation(session)
    program_role_handler = program_roles.ProgramRolesHandler()
    program_role_handler.after_flush(session)
    audit_role_handler = audit_roles.AuditRolesHandler()
    audit_role_handler.after_flush(session)
    relationship_deletion.after_flush(session)

    if hasattr(flask.g, "new_wf_acls"):
        flask.g.new_wf_acls.update(workflow.get_new_wf_acls(session))
    else:
        flask.g.new_wf_acls = workflow.get_new_wf_acls(session)

    if hasattr(flask.g, "deleted_wf_objects"):
        flask.g.deleted_wf_objects.update(
            workflow.get_deleted_wf_objects(session))
    else:
        flask.g.deleted_wf_objects = workflow.get_deleted_wf_objects(session)

    workflow.handle_acl_changes()
예제 #2
0
def after_flush(session, _):
    """Handle all ACL hooks after after flush."""

    relationship.handle_relationship_creation(session)
    access_control_list.handle_acl_creation(session)
    program_role_handler = program_roles.ProgramRolesHandler()
    program_role_handler.after_flush(session)
    audit_role_handler = audit_roles.AuditRolesHandler()
    audit_role_handler.after_flush(session)
    relationship_deletion.after_flush(session)
    workflow.handle_acl_changes(session)
예제 #3
0
def propagate_all():
  """Re-evaluate propagation for all objects."""
  with utils.benchmark("Run propagate_all"):
    from ggrc_workflows.models.hooks import workflow

    with utils.benchmark("Get non propagated acl ids"):
      query = db.session.query(
          all_models.AccessControlList.object_type,
          all_models.AccessControlList.id,
      ).filter(
          all_models.AccessControlList.parent_id.is_(None),
      )
      non_wf_acl_ids = []
      wf_acl_ids = []
      for object_type, acl_id in query:
        if object_type == "Workflow":
          wf_acl_ids.append(acl_id)
        else:
          non_wf_acl_ids.append(acl_id)

    with utils.benchmark("Propagate normal acl entries"):
      count = len(non_wf_acl_ids)
      propagated_count = 0
      for acl_ids in utils.list_chunks(non_wf_acl_ids):
        propagated_count += len(acl_ids)
        logger.info("Propagating ACL entries: %s/%s", propagated_count, count)
        _delete_propagated_acls(acl_ids)

        flask.g.new_acl_ids = acl_ids
        flask.g.new_relationship_ids = set()
        flask.g.deleted_objects = set()
        propagate()

    with utils.benchmark("Propagate WF related acl entries"):
      count = len(wf_acl_ids)
      propagated_count = 0
      for acl_ids in utils.list_chunks(wf_acl_ids):
        propagated_count += len(acl_ids)
        logger.info(
            "Propagating WF ACL entries: %s/%s",
            propagated_count,
            count
        )
        _delete_propagated_acls(acl_ids)

        flask.g.new_wf_acls = set(acl_ids)
        flask.g.new_wf_comment_ct_ids = set()
        flask.g.deleted_wf_objects = set()
        workflow.handle_acl_changes()
예제 #4
0
def propagate_all():
    """Re-evaluate propagation for all objects."""
    with utils.benchmark("Run propagate_all"):
        from ggrc_workflows.models.hooks import workflow

        with utils.benchmark("Get non propagated acl ids"):
            query = db.session.query(
                all_models.AccessControlList.object_type,
                all_models.AccessControlList.id,
            ).filter(all_models.AccessControlList.parent_id.is_(None), )
            non_wf_acl_ids = []
            wf_acl_ids = []
            for object_type, acl_id in query:
                if object_type == "Workflow":
                    wf_acl_ids.append(acl_id)
                else:
                    non_wf_acl_ids.append(acl_id)

        with utils.benchmark("Propagate normal acl entries"):
            count = len(non_wf_acl_ids)
            propagated_count = 0
            for acl_ids in utils.list_chunks(non_wf_acl_ids):
                propagated_count += len(acl_ids)
                logger.info("Propagating ACL entries: %s/%s", propagated_count,
                            count)
                _delete_propagated_acls(acl_ids)

                flask.g.new_acl_ids = acl_ids
                flask.g.new_relationship_ids = set()
                flask.g.deleted_objects = set()
                propagate()

        with utils.benchmark("Propagate WF related acl entries"):
            count = len(wf_acl_ids)
            propagated_count = 0
            for acl_ids in utils.list_chunks(wf_acl_ids):
                propagated_count += len(acl_ids)
                logger.info("Propagating WF ACL entries: %s/%s",
                            propagated_count, count)
                _delete_propagated_acls(acl_ids)

                flask.g.new_wf_acls = set(acl_ids)
                flask.g.new_wf_comment_ct_ids = set()
                flask.g.deleted_wf_objects = set()
                workflow.handle_acl_changes()
예제 #5
0
def after_commit():
  """ACL propagation after commit action."""
  with benchmark("General acl propagation"):
    propagation.propagate()
  with benchmark("Workflow acl propagation"):
    workflow.handle_acl_changes()
예제 #6
0
def after_commit():
    """ACL propagation after commit action."""
    with benchmark("General acl propagation"):
        propagation.propagate()
    with benchmark("Workflow acl propagation"):
        workflow.handle_acl_changes()
예제 #7
0
def after_commit():
    propagation.propagate()
    workflow.handle_acl_changes()