<commit_before>#!/usr/bin/python

'''
Validates command to gather logs from a cluster

Developer usage:

   ssh -i log_gathering_key use-tower2.ops.rhcloud.com -- -c <clusterName> -u <kerberosID>

clusterName is checked against a list of known/valid cluster names.

kerberosID is the Kerberos ID of the developer requesting logs, for tracking purposes
'''

# pylint: disable=invalid-name
# pylint: disable=logging-not-lazy
# pylint: disable=broad-except

# The log_gathering_key is kept in the shared-secrets repo. It is generated and
# rotated weekly by the Jenkins job cluster/rotate-log-access-key. The public
# key in .ssh/authorized_keys looks like this:
#
#  command="verify-gather-logs-operations.py" ssh-rsa ThePublicKey logs_access_key_week_22-YMD-H:M:S

import argparse
import getpass
import os
import re
import sys
import socket
import logging
import logging.handlers

# The list of valid cluster names to request logs from
VALID_CLUSTER_NAMES = [
    'free-int',
    'free-stg',
    'starter-us-east-1',
    'starter-us-east-2',
    'starter-us-west-2'
]

# This regex is used to check that the provided node names look like a valid
# node name (i.e. from "oc get node") or an inventory host name.
#
# In order to keep the check simple this doesn't aim at RFC 1123 compliance,
# only that the provided node name is "similar enough" to a valid hostname
# and that it matches what our cluster's node names/inventory names look like
#
# Here labels must start with a letter. This prevents using IPs to identify
# nodes (the log gathering script should be modified to allow IPs).
#
# NOTE: this is only an input sanity check, not a full verification that the
# provided node names actually exist. The full/final hostname validation
# happens in the log gathering script itself by accessing the cluster's
# ansible inventory
HOSTNAME_RE = re.compile(
    r'([a-z][a-z\d-]{0,62}\.)*'<commit_msg>Add us-west-1 and ca-central-1 as starter clusters for log gathering<commit_after>#!/usr/bin/python

'''
Validates command to gather logs from a cluster

Developer usage:

   ssh -i log_gathering_key use-tower2.ops.rhcloud.com -- -c <clusterName> -u <kerberosID>

clusterName is checked against a list of known/valid cluster names.

kerberosID is the Kerberos ID of the developer requesting logs, for tracking purposes
'''

# pylint: disable=invalid-name
# pylint: disable=logging-not-lazy
# pylint: disable=broad-except

# The log_gathering_key is kept in the shared-secrets repo. It is generated and
# rotated weekly by the Jenkins job cluster/rotate-log-access-key. The public
# key in .ssh/authorized_keys looks like this:
#
#  command="verify-gather-logs-operations.py" ssh-rsa ThePublicKey logs_access_key_week_22-YMD-H:M:S

import argparse
import getpass
import os
import re
import sys
import socket
import logging
import logging.handlers

# The list of valid cluster names to request logs from
VALID_CLUSTER_NAMES = [
    'free-int',
    'free-stg',
    'starter-ca-central-1',
    'starter-us-east-1',
    'starter-us-east-2',
    'starter-us-west-1',
    'starter-us-west-2'
]

# This regex is used to check that the provided node names look like a valid
# node name (i.e. from "oc get node") or an inventory host name.
#
# In order to keep the check simple this doesn't aim at RFC 1123 compliance,
# only that the provided node name is "similar enough" to a valid hostname
# and that it matches what our cluster's node names/inventory names look like
#
# Here labels must start with a letter. This prevents using IPs to identify
# nodes (the log gathering script should be modified to allow IPs).
#
# NOTE: this is only an input sanity check, not a full verification that the
# provided node names actually exist. The full/final hostname validation
# happens in the log gathering script itself by accessing the cluster's
# ansible inventory
HOSTNAME_RE = re.compile(
    r'([a-z][a-z\d-]{0,62}\.)*'
{'fraction_non_alphanumeric': 0.08491048593350384, 'fraction_numerical': 0.0076726342710997444, 'mean_word_length': 4.105744125326371, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4883154', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1181, 'n_words': 490}