Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
0
9.3M
import logging import re import sys from collections import OrderedDict as OrdDict from collections import namedtuple from operator import itemgetter, attrgetter from avclass import DEFAULT_TAX_PATH, DEFAULT_TAG_PATH, DEFAULT_EXP_PATH # Set logging log = logging.getLogger(__name__) # Prefix to identify platform tags...
#!/usr/bin/env python import sys def tp_fp_fn(CORRECT_SET, GUESS_SET): """ INPUT: dictionary with the elements in the cluster from the ground truth (CORRECT_SET) and dictionary with the elements from the estimated cluster (ESTIMATED_SET). OUTPUT: number of True Positives (elements in both clusters...
#!/usr/bin/env python3 import argparse import gzip import json import logging import os import string import sys import traceback from operator import itemgetter try: from avclass import DEFAULT_TAX_PATH, DEFAULT_TAG_PATH, DEFAULT_EXP_PATH from avclass.common import AvLabels, Taxonomy, SampleInfo from av...
#!/usr/bin/env python3 import argparse import json import os import uuid import sys try: from avclass import DEFAULT_TAX_PATH, DEFAULT_TAG_PATH, DEFAULT_EXP_PATH from avclass.common import Taxonomy, Tagging except ModuleNotFoundError: sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file_...
#!/usr/bin/env python3 import argparse import os import sys try: from avclass import DEFAULT_TAX_PATH, DEFAULT_TAG_PATH, DEFAULT_EXP_PATH from avclass.common import Taxonomy, Tagging, Expansion except ModuleNotFoundError: sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) fro...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse import logging import os import sys from collections import namedtuple from operator import itemgetter # from Levenshtein import ratio as levenshtein_ratio try: from avclass import DEFAULT_TAX_PATH, DEFAULT_TAG_PATH, DEFAULT_EXP_PATH from avclass...
import os AVCLASS_ROOT = os.path.dirname(os.path.abspath(__file__)) DATA_FOLDER = os.path.join(AVCLASS_ROOT, 'data/') RESOURCE_TAG = "default.tagging" RESOURCE_TAX = "default.taxonomy" RESOURCE_EXP = "default.expansion" DEFAULT_TAX_PATH = os.path.join(DATA_FOLDER, RESOURCE_TAX) DEFAULT_TAG_PATH = os.path.join(DATA_F...
#!/usr/bin/env python3 """Command-line tool for easily managing BinaryAlert.""" import argparse import os import sys from cli import __version__ from cli.manager import Manager def main() -> None: """Main command dispatcher.""" if not (sys.version_info.major == 3 and sys.version_info.minor in {6, 7}): ...
"""BinaryAlert configuration management.""" import base64 import getpass import os import re import subprocess from typing import Any import boto3 import hcl from cli.exceptions import InvalidConfigError # File locations PARENT_DIR = os.path.dirname(os.path.realpath(__file__)) # Directory containing this file. TERR...
"""Worker task for adding things to a queue.""" from multiprocessing import JoinableQueue, Process import time from typing import List import boto3 class EnqueueTask: """A Task to send a batch of records to SQS.""" def __init__(self, messages: List[str]) -> None: """Initialize a Task with up to 10 S...
"""Custom exceptions in the BinaryAlert CLI.""" class ManagerError(Exception): """Top-level exception for Manager errors.""" class InvalidConfigError(ManagerError): """BinaryAlert config is not valid.""" class TestFailureError(ManagerError): """Exception raised when a BinaryAlert test fails."""
"""BinaryAlert management utility.""" from datetime import datetime, timedelta import gzip import inspect import json import multiprocessing from multiprocessing import JoinableQueue import os import subprocess import sys from typing import Any, Callable, Dict, Generator, Iterable, Optional, Set, Tuple import unittest ...
"""BinaryAlert release version""" __version__ = '1.2.0'
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # BinaryAlert documentation build configuration file, created by # sphinx-quickstart on Tue Sep 12 11:56:50 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this ...
"""Builds the deployment packages for all of the Lambda functions.""" import glob import os import pathlib import shutil import stat import subprocess import sys import tempfile from typing import Callable import zipfile from lambda_functions.analyzer.common import COMPILED_RULES_FILENAME from rules.compile_rules impo...
"""Collection of boto3 calls to AWS resources for the analyzer function.""" import json from typing import Dict, List, Optional, Set, Tuple, Union import boto3 from boto3.dynamodb.conditions import Key from botocore.client import Config from botocore.exceptions import ClientError # BinaryInfo is imported here just fo...
"""Keeps track of all information associated with and computed about a binary.""" import os import subprocess import tempfile import time from typing import Any, Dict, List, Set import uuid from lambda_functions.analyzer import analyzer_aws_lib, file_hash from lambda_functions.analyzer.common import LOGGER from lambda...
"""Common resources shared among the analyzer components.""" import logging import os LOGGER = logging.getLogger() LOGGER.setLevel(logging.INFO) # Define the name and location of the compiled YARA rules file. COMPILED_RULES_FILENAME = 'compiled_yara_rules.bin' THIS_DIRECTORY = os.path.dirname(os.path.realpath(__file_...
"""Memory-efficient file hashing.""" import hashlib from typing import Generator, IO, Tuple MB = 2 ** 20 # ~ 1 million bytes def _read_in_chunks(file_object: IO[bytes], chunk_size: int = 2*MB) -> Generator[bytes, None, None]: """Read a file in fixed-size chunks (to minimize memory usage for large files). A...
"""AWS Lambda function for testing a binary against a list of YARA rules.""" # Expects the following environment variables: # NO_MATCHES_SNS_TOPIC_ARN: Optional ARN of an SNS topic to notify if there are no YARA matches. # YARA_MATCHES_DYNAMO_TABLE_NAME: Name of the Dynamo table which stores YARA match results. # ...
"""Wrapper around YARA analysis.""" import collections import json import os import subprocess from typing import Any, Dict, List import yara from lambda_functions.analyzer.common import LOGGER # YARA matches from both yara-python and yextend are stored in this generic YaraMatch tuple. YaraMatch = collections.named...
"""Lambda function to copy a binary from CarbonBlack into the BinaryAlert input S3 bucket.""" # Expects the following environment variables: # CARBON_BLACK_URL: URL of the CarbonBlack server. # ENCRYPTED_CARBON_BLACK_API_TOKEN: API token, encrypted with KMS. # TARGET_S3_BUCKET: Name of the S3 bucket in which to s...
"""Update YARA rules cloned from remote sources.""" from fnmatch import fnmatch import json import os import shutil import subprocess import tempfile from typing import Generator, List, Optional RULES_DIR = os.path.dirname(os.path.realpath(__file__)) # Directory containing this file. REMOTE_RULE_SOURCES = os.path.joi...
"""Compile all of the YARA rules into a single binary file.""" import os from typing import Generator import yara RULES_DIR = os.path.dirname(os.path.realpath(__file__)) # Directory containing this file. def _find_yara_files() -> Generator[str, None, None]: """Find all .yar[a] files in the rules directory. ...
"""Utilities common to several different unit tests.""" class MockLambdaContext: """http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html""" def __init__(self, function_version: int = 1, time_limit_ms: int = 30000, decrement_ms: int = 10000) -> None: self.function_ver...
"""Upload test files to S3 and see if the expected matches appear in Dynamo.""" import hashlib import json import os import time from typing import Dict, List import uuid import boto3 TEST_DIR = os.path.dirname(os.path.realpath(__file__)) TEST_FILES = ['eicar.txt', 'eicar.tar.gz.bz2', 'eicar_packed.py.upx', 'eicar_te...
"""Unit tests for cli/config.py.""" # pylint: disable=no-self-use,protected-access import base64 import getpass import subprocess import sys from unittest import mock import boto3 from cli import config as config_module from cli.config import BinaryAlertConfig, CONFIG_FILE from cli.exceptions import InvalidConfigErro...
"""Unit tests for cli/enqueue_task.py""" # pylint: disable=no-self-use,protected-access from multiprocessing import JoinableQueue import time from typing import Any, Dict import unittest from unittest import mock import boto3 from cli import enqueue_task class MockQueue: """Mock SQS queue which fails half of th...
"""Unit tests for cli/manager.py""" # pylint: disable=protected-access,too-many-public-methods import collections import inspect import subprocess from unittest import mock from cli import config as config_module from cli import manager as manager_module from cli.config import BinaryAlertConfig from cli.exceptions imp...
"""Shared utilities for CLI test methods.""" import os import sys from pyfakefs import fake_filesystem_unittest from cli.config import CONFIG_FILE, VARIABLES_FILE def mock_input(prompt: str) -> str: """Mock for the user input() function to automatically respond with valid answers.""" # pylint: disable=too-m...
"""Test lambda_functions/build.py.""" import os import tempfile from typing import List, Set import unittest from unittest import mock import zipfile from lambda_functions import build def _mock_pip_main(args_list: List[str]) -> None: """Mock pip install just creates the target directories.""" install_direct...
End of preview. Expand in Data Studio

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Python Code Dataset

This dataset contains extracted Python code from various repositories for fine-tuning code-generation models.

Downloads last month
9