コード例 #1
0
def cleanup_rpr(
    neo4j_session: neo4j.Session,
    node_label: str,
    relationship_name: str,
    update_tag: int,
    current_aws_id: str,
) -> None:
    logger.info("Cleaning up relationship '%s' for node label '%s'",
                relationship_name, node_label)
    cleanup_rpr_query = Template("""
        MATCH (:AWSAccount{id: {AWS_ID}})-[:RESOURCE]->(principal:AWSPrincipal)-[r:$relationship_name]->
        (resource:$node_label)
        WHERE r.lastupdated <> {UPDATE_TAG}
        WITH r LIMIT {LIMIT_SIZE}  DELETE (r) return COUNT(*) as TotalCompleted
    """)
    cleanup_rpr_query_template = cleanup_rpr_query.safe_substitute(
        node_label=node_label,
        relationship_name=relationship_name,
    )

    statement = GraphStatement(
        cleanup_rpr_query_template,
        {
            'UPDATE_TAG': update_tag,
            'AWS_ID': current_aws_id
        },
        True,
        1000,
    )
    statement.run(neo4j_session)
コード例 #2
0
ファイル: job.py プロジェクト: vvalorous/cartography
def _get_statements_from_json(blob):
    """
    Deserialize all statements from the JSON blob.
    """
    statements = []
    for statement_data in blob["statements"]:
        statement = GraphStatement.create_from_json(statement_data)
        statements.append(statement)

    return statements
コード例 #3
0
ファイル: job.py プロジェクト: rajkrishnamurthy/cartography
def _get_statements_from_json(blob: Dict, short_job_name: Optional[str] = None) -> List[GraphStatement]:
    """
    Deserialize all statements from the JSON blob.
    """
    statements: List[GraphStatement] = []
    for i, statement_data in enumerate(blob["statements"]):
        # i+1 to make it 1-based and not 0-based to help with log readability
        statement: GraphStatement = GraphStatement.create_from_json(statement_data, short_job_name, i + 1)
        statements.append(statement)

    return statements