# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Constants for VirusTotal.""" from upvote.shared import constants RESPONSE_CODE = constants.Namespace(tuples=[ ('UNKNOWN', 0), ('PENDING', -2), ('ANALYZED', 1), ]) ANALYSIS_STATE = constants.UppercaseNamespace( names=('UNKNOWN', 'PENDING', 'ANALYZED')) ANALYSIS_STATE.DefineMap('FROM_RESPONSE_CODE', { RESPONSE_CODE.UNKNOWN: ANALYSIS_STATE.UNKNOWN, RESPONSE_CODE.PENDING: ANALYSIS_STATE.PENDING, RESPONSE_CODE.ANALYZED: ANALYSIS_STATE.ANALYZED, }) # NOTE: This list contains all scanners that will be used in displaying results # to users. Its default is the list of all VirusTotal scanners (as of 17-11-01). # These can be added or removed based on institutional trust, false-positive # tolerance, or just general preference. TRUSTED_AV_VENDORS = set([ 'ALYac', 'AVG', 'AVware', 'Ad-Aware', 'AegisLab', 'AhnLab-V3', 'Antiy-AVL', 'Arcabit', 'Avast', 'Avast-Mobile', 'Avira', 'Baidu', 'BitDefender', 'Bkav', 'CAT-QuickHeal', 'CMC', 'ClamAV', 'Comodo', 'Cyren', 'DrWeb', 'ESET-NOD32', 'Emsisoft',
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """List of constants for BigQueryRow SchemaField ordering.""" import upvote.gae.shared.common.google_cloud_lib_fixer # pylint: disable=unused-import # pylint: disable=g-bad-import-order,g-import-not-at-top from google.cloud import bigquery as bq from upvote.shared import constants _BQ_TYPE = constants.UppercaseNamespace( ['STRING', 'TIMESTAMP', 'BOOLEAN', 'INTEGER']) _BQ_MODE = constants.UppercaseNamespace(['REPEATED', 'NULLABLE', 'REQUIRED']) INSERT_ID_FIELD = bq.SchemaField(name='insert_id', field_type=_BQ_TYPE.STRING) VOTE = [ bq.SchemaField(name='sha256', field_type=_BQ_TYPE.STRING), bq.SchemaField(name='timestamp', field_type=_BQ_TYPE.TIMESTAMP), bq.SchemaField(name='upvote', field_type=_BQ_TYPE.BOOLEAN), bq.SchemaField(name='weight', field_type=_BQ_TYPE.INTEGER), bq.SchemaField(name='platform', field_type=_BQ_TYPE.STRING), bq.SchemaField(name='target_type', field_type=_BQ_TYPE.STRING), bq.SchemaField(name='voter', field_type=_BQ_TYPE.STRING) ]
def testUppercaseNamespace(self): namespace = constants.UppercaseNamespace(['Aa', 'Bb', 'Cc']) self.assertEqual('AA', namespace.AA) self.assertEqual('BB', namespace.BB) self.assertEqual('CC', namespace.CC) self.assertSetEqual(set(['AA', 'BB', 'CC']), namespace.SET_ALL)
import time import upvote.gae.lib.cloud.google_cloud_lib_fixer # pylint: disable=unused-import # pylint: disable=g-bad-import-order,g-import-not-at-top from google.cloud import bigquery from google.cloud import exceptions from google.appengine.api import memcache from google.appengine.ext import deferred from google.appengine.ext import ndb from upvote.gae.bigquery import monitoring from upvote.gae import settings from upvote.shared import constants FIELD_TYPE = constants.UppercaseNamespace( ['BOOLEAN', 'INTEGER', 'STRING', 'TIMESTAMP']) FIELD_TYPE_MAP = { FIELD_TYPE.BOOLEAN: {bool}, FIELD_TYPE.INTEGER: {int, long}, FIELD_TYPE.STRING: {str, unicode}, FIELD_TYPE.TIMESTAMP: {datetime.datetime}, } MODE = constants.UppercaseNamespace(['NULLABLE', 'REPEATED', 'REQUIRED']) Column = collections.namedtuple('Column', ['name', 'field_type', 'mode', 'choices']) Column.__new__.__defaults__ = (None, FIELD_TYPE.STRING, MODE.REQUIRED, set()) # pylint: disable=protected-access