prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>hamming_distance.py<|end_file_name|><|fim▁begin|>def hamming(s,t): dist = 0 for x in range(len(s)): if s[x]!=t[x]: <|fim_middle|> return dist <|fim▁end|>
dist+=1
<|file_name|>hamming_distance.py<|end_file_name|><|fim▁begin|>def <|fim_middle|>(s,t): dist = 0 for x in range(len(s)): if s[x]!=t[x]: dist+=1 return dist <|fim▁end|>
hamming
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """digitalocean API to manage droplets""" __version__ = "1.16.0" __author__ = "Lorenzo Setale ( http://who.is.lorenzo.setale.me/? )" __author_email__ = "[email protected]" __license__ = "LGPL v3" __copyright__ = "Copyright (c) 2012-2020 Lorenzo Setale" from .Manager import Manager from .Droplet import Droplet, DropletError, BadKernelObject, BadSSHKeyFormat from .Region import Region from .Size import Size from .Image import Image from .Action import Action from .Account import Account from .Balance import Balance from .Domain import Domain from .Record import Record from .SSHKey import SSHKey from .Kernel import Kernel<|fim▁hole|>from .LoadBalancer import LoadBalancer from .LoadBalancer import StickySessions, ForwardingRule, HealthCheck from .Certificate import Certificate from .Snapshot import Snapshot from .Project import Project from .Firewall import Firewall, InboundRule, OutboundRule, Destinations, Sources from .VPC import VPC<|fim▁end|>
from .FloatingIP import FloatingIP from .Volume import Volume from .baseapi import Error, EndPointError, TokenError, DataReadError, NotFoundError from .Tag import Tag
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms from miniURL.models import Redirection <|fim▁hole|>#Pour faire un formulaire depuis un modèle. (/!\ héritage différent) class RedirectionForm(forms.ModelForm): class Meta: model = Redirection fields = ('real_url', 'pseudo') # Pour récupérer des données cel apeut ce faire avec un POST # ou directement en donnant un objet du modele : #form = ArticleForm(instance=article) # article est bien entendu un objet d'Article quelconque dans la base de données # Le champs est ainsi préremplit. # Quand on a recu une bonne formeModele il suffit de save() pour la mettre en base<|fim▁end|>
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms from miniURL.models import Redirection #Pour faire un formulaire depuis un modèle. (/!\ héritage différent) class RedirectionForm(forms.ModelForm): cla<|fim_middle|> Pour récupérer des données cel apeut ce faire avec un POST # ou directement en donnant un objet du modele : #form = ArticleForm(instance=article) # article est bien entendu un objet d'Article quelconque dans la base de données # Le champs est ainsi préremplit. # Quand on a recu une bonne formeModele il suffit de save() pour la mettre en base<|fim▁end|>
ss Meta: model = Redirection fields = ('real_url', 'pseudo') #
<|file_name|>forms.py<|end_file_name|><|fim▁begin|>from django import forms from miniURL.models import Redirection #Pour faire un formulaire depuis un modèle. (/!\ héritage différent) class RedirectionForm(forms.ModelForm): class Meta: mod<|fim_middle|> Pour récupérer des données cel apeut ce faire avec un POST # ou directement en donnant un objet du modele : #form = ArticleForm(instance=article) # article est bien entendu un objet d'Article quelconque dans la base de données # Le champs est ainsi préremplit. # Quand on a recu une bonne formeModele il suffit de save() pour la mettre en base<|fim▁end|>
el = Redirection fields = ('real_url', 'pseudo') #
<|file_name|>tag_ports_during_bulk_creation.py<|end_file_name|><|fim▁begin|># Copyright (c) 2019 Verizon Media # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # 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<|fim▁hole|> ALIAS = 'tag-ports-during-bulk-creation' IS_SHIM_EXTENSION = True IS_STANDARD_ATTR_EXTENSION = False NAME = 'Tag Ports During Bulk Creation' DESCRIPTION = 'Allow to tag ports during bulk creation' UPDATED_TIMESTAMP = '2019-12-29T19:00:00-00:00' RESOURCE_ATTRIBUTE_MAP = {} SUB_RESOURCE_ATTRIBUTE_MAP = {} ACTION_MAP = {} REQUIRED_EXTENSIONS = [] OPTIONAL_EXTENSIONS = [] ACTION_STATUS = {}<|fim▁end|>
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License.
<|file_name|>0001_initial.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='Page', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('title', models.CharField(unique=True, max_length=150)),<|fim▁hole|> }, bases=(models.Model,), ), ]<|fim▁end|>
('slug', models.SlugField(unique=True, max_length=150)), ('posted', models.DateTimeField(auto_now_add=True, db_index=True)), ], options={
<|file_name|>0001_initial.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): <|fim_middle|> <|fim▁end|>
dependencies = [ ] operations = [ migrations.CreateModel( name='Page', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('title', models.CharField(unique=True, max_length=150)), ('slug', models.SlugField(unique=True, max_length=150)), ('posted', models.DateTimeField(auto_now_add=True, db_index=True)), ], options={ }, bases=(models.Model,), ), ]
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os<|fim▁hole|> class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results<|fim▁end|>
import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): <|fim_middle|> <|fim▁end|>
def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): <|fim_middle|> def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini']
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): <|fim_middle|> def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
return self.required_files
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): <|fim_middle|> <|fim▁end|>
check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): <|fim_middle|> return check_results <|fim▁end|>
config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): <|fim_middle|> if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): <|fim_middle|> else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': <|fim_middle|> elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['medium'].append('Register globals is on (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': <|fim_middle|> else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['ok'].append('Register globals is off (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: <|fim_middle|> else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Unknown value for register globals (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: <|fim_middle|> if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Register globals not found (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): <|fim_middle|> else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': <|fim_middle|> elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': <|fim_middle|> else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Safe mode is off (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: <|fim_middle|> else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: <|fim_middle|> if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Safe mode not found (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): <|fim_middle|> else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': <|fim_middle|> elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': <|fim_middle|> elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['ok'].append('Display errors is off (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': <|fim_middle|> else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Display errors set to stderr (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: <|fim_middle|> else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Unknown value for display errors (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: <|fim_middle|> if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Display errors not found (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): <|fim_middle|> else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': <|fim_middle|> elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['low'].append('Expose PHP is on (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': <|fim_middle|> else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['ok'].append('Expose PHP is off (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: <|fim_middle|> else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: <|fim_middle|> return check_results <|fim▁end|>
check_results['info'].append('Expose PHP not found (%s)' % (php_conf))
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def <|fim_middle|>(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
__init__
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def <|fim_middle|>(self): return self.required_files def analyze(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
requires
<|file_name|>php.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # HnTool rules - php # Copyright (C) 2009-2010 Candido Vieira <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # import os import ConfigParser import HnTool.modules.util from HnTool.modules.rule import Rule as MasterRule class Rule(MasterRule): def __init__(self, options): MasterRule.__init__(self, options) self.short_name="php" self.long_name="Checks security problems on php config file" self.type="config" self.required_files = ['/etc/php5/apache2/php.ini', '/etc/php5/cli/php.ini', '/etc/php.ini'] def requires(self): return self.required_files def <|fim_middle|>(self, options): check_results = self.check_results conf_files = self.required_files for php_conf in conf_files: if os.path.isfile(php_conf): config = ConfigParser.ConfigParser() try: config.read(php_conf) except ConfigParser.ParsingError, (errno, strerror): check_results['info'].append('Could not parse %s: %s' % (php_conf, strerror)) continue if not config.has_section('PHP'): check_results['info'].append('%s is not a PHP config file' % (php_conf)) continue if config.has_option('PHP', 'register_globals'): rg = config.get('PHP', 'register_globals').lower() if rg == 'on': check_results['medium'].append('Register globals is on (%s)' % (php_conf)) elif rg == 'off': check_results['ok'].append('Register globals is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for register globals (%s)' % (php_conf)) else: check_results['info'].append('Register globals not found (%s)' % (php_conf)) if config.has_option('PHP', 'safe_mode'): sm = config.get('PHP', 'safe_mode').lower() if sm == 'on': check_results['low'].append('Safe mode is on (fake security) (%s)' % (php_conf)) elif sm == 'off': check_results['info'].append('Safe mode is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for safe mode (%s)' % (php_conf)) else: check_results['info'].append('Safe mode not found (%s)' % (php_conf)) if config.has_option('PHP', 'display_errors'): de = config.get('PHP', 'display_errors').lower() if de == 'on': check_results['medium'].append('Display errors is on (stdout) (%s)' % (php_conf)) elif de == 'off': check_results['ok'].append('Display errors is off (%s)' % (php_conf)) elif de == 'stderr': check_results['info'].append('Display errors set to stderr (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for display errors (%s)' % (php_conf)) else: check_results['info'].append('Display errors not found (%s)' % (php_conf)) if config.has_option('PHP', 'expose_php'): ep = config.get('PHP', 'expose_php').lower() if ep == 'on': check_results['low'].append('Expose PHP is on (%s)' % (php_conf)) elif ep == 'off': check_results['ok'].append('Expose PHP is off (%s)' % (php_conf)) else: check_results['info'].append('Unknown value for expose PHP (%s)' % (php_conf)) else: check_results['info'].append('Expose PHP not found (%s)' % (php_conf)) return check_results <|fim▁end|>
analyze
<|file_name|>setup.py<|end_file_name|><|fim▁begin|># Copyright 2017 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except # in compliance with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 #<|fim▁hole|># 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. # This setup file is used when running cloud training or cloud dataflow jobs. from setuptools import setup, find_packages setup( name='trainer', version='1.0.0', packages=find_packages(), description='Google Cloud Datalab helper sub-package', author='Google', author_email='[email protected]', keywords=[ ], license="Apache Software License", long_description=""" """, install_requires=[ 'tensorflow==1.15.2', 'protobuf==3.1.0', 'pillow==6.2.0', # ML Engine does not have PIL installed ], package_data={ }, data_files=[], )<|fim▁end|>
# Unless required by applicable law or agreed to in writing, software distributed under the License
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin")<|fim▁hole|> # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url())<|fim▁end|>
class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True)
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): <|fim_middle|> @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
@cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard")
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) <|fim_middle|> @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
self.redirect("/admin/dashboard")
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): <|fim_middle|> @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
@cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard")
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): <|fim_middle|> @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
self.redirect("/admin/dashboard")
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): <|fim_middle|> @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
@cyclone.web.authenticated def get(self): self.render("about.html")
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): <|fim_middle|> @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
self.render("about.html")
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): <|fim_middle|> <|fim▁end|>
def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url())
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): <|fim_middle|> @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid()
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): <|fim_middle|> <|fim▁end|>
self.redirect(self.get_toughcloud_url())
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): <|fim_middle|> else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid()
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: <|fim_middle|> @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid()
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def <|fim_middle|>(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
get
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def <|fim_middle|>(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
get
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def <|fim_middle|>(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
get
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def <|fim_middle|>(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def get(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
get_toughcloud_url
<|file_name|>index.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python #coding:utf-8 import cyclone.auth import cyclone.escape import cyclone.web import datetime import time import os from beaker.cache import cache_managers from toughradius.manage.base import BaseHandler from toughlib.permit import permit from toughradius.manage import models from toughradius.manage.settings import * from toughradius.common import tools import psutil @permit.route(r"/admin") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): # cpuuse = psutil.cpu_percent(interval=None, percpu=True) # memuse = psutil.virtual_memory() # online_count = self.db.query(models.TrOnline.id).count() # user_total = self.db.query(models.TrAccount.account_number).filter_by(status=1).count() # self.render("index.html",config=self.settings.config, # cpuuse=cpuuse,memuse=memuse,online_count=online_count,user_total=user_total) self.redirect("/admin/dashboard") @permit.route(r"/") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.redirect("/admin/dashboard") @permit.route(r"/about") class HomeHandler(BaseHandler): @cyclone.web.authenticated def get(self): self.render("about.html") @permit.route(r"/toughcloud/service/register") class ToughcloudRegisterHandler(BaseHandler): def get_toughcloud_url(self): if os.environ.get("TR_DEV"): return 'http://127.0.0.1:9079/customer/license/request?sid=%s'%tools.get_sys_uuid() else: return 'https://www.toughcloud.net/customer/license/request?sid=%s'%tools.get_sys_uuid() @cyclone.web.authenticated def <|fim_middle|>(self): self.redirect(self.get_toughcloud_url()) <|fim▁end|>
get
<|file_name|>HeadsetTester.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from Headset import Headset import logging import time puerto = 'COM3' headset = Headset(logging.INFO) try: headset.connect(puerto, 115200) except Exception, e: raise e <|fim▁hole|>headset.stopReading() headset.closePort() print "-----------------------------------------" print "Is conected? " + str(headset.isConnected()) print headset.getStatus()<|fim▁end|>
print "Is conected? " + str(headset.isConnected()) print "-----------------------------------------" headset.startReading(persist_data=True) time.sleep(5)
<|file_name|>_hasidof.py<|end_file_name|><|fim▁begin|># # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2002-2006 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # #------------------------------------------------------------------------- # # Standard Python modules # #------------------------------------------------------------------------- from ....const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext #------------------------------------------------------------------------- # # GRAMPS modules # #------------------------------------------------------------------------- from .. import HasGrampsId #-------------------------------------------------------------------------<|fim▁hole|># HasIdOf # #------------------------------------------------------------------------- class HasIdOf(HasGrampsId): """Rule that checks for a person with a specific GRAMPS ID""" name = _('Person with <Id>') description = _("Matches person with a specified Gramps ID")<|fim▁end|>
#
<|file_name|>_hasidof.py<|end_file_name|><|fim▁begin|># # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2002-2006 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # #------------------------------------------------------------------------- # # Standard Python modules # #------------------------------------------------------------------------- from ....const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext #------------------------------------------------------------------------- # # GRAMPS modules # #------------------------------------------------------------------------- from .. import HasGrampsId #------------------------------------------------------------------------- # # HasIdOf # #------------------------------------------------------------------------- class HasIdOf(HasGrampsId): <|fim_middle|> <|fim▁end|>
"""Rule that checks for a person with a specific GRAMPS ID""" name = _('Person with <Id>') description = _("Matches person with a specified Gramps ID")
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) <|fim▁hole|> @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret))<|fim▁end|>
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): <|fim_middle|> class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
def decorator(f): f.http_route = path f.http_method = method return f return decorator
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): <|fim_middle|> return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
f.http_route = path f.http_method = method return f
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): <|fim_middle|> <|fim▁end|>
prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret))
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): <|fim_middle|> @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
self.ndb = ndb self.config = config
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): <|fim_middle|> @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret))
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): <|fim_middle|> @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start()
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): <|fim_middle|> @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec)
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): <|fim_middle|> @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node)
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): <|fim_middle|> @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
return bottle.template('{{!ret}}', ret=json.dumps(self.config))
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): <|fim_middle|> @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path)
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): <|fim_middle|> @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret))
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): <|fim_middle|> <|fim▁end|>
ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret))
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': <|fim_middle|> return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
ret[name]['config'] = spec.nl_kwarg
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def <|fim_middle|>(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
route
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def <|fim_middle|>(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
decorator
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def <|fim_middle|>(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
__init__
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def <|fim_middle|>(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
sources_list
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def <|fim_middle|>(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
sources_restart
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def <|fim_middle|>(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
sources_add
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def <|fim_middle|>(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
sources_del
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def <|fim_middle|>(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
config_get
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def <|fim_middle|>(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
config_dump
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def <|fim_middle|>(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def query(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
view
<|file_name|>api.py<|end_file_name|><|fim▁begin|>import json import bottle from pyrouted.util import make_spec def route(method, path): def decorator(f): f.http_route = path f.http_method = method return f return decorator class APIv1(object): prefix = '/v1' def __init__(self, ndb, config): self.ndb = ndb self.config = config @route('GET', '/sources') def sources_list(self, mode='short'): ret = {} mode = bottle.request.query.mode or mode for name, spec in self.ndb.sources.items(): ret[name] = {'class': spec.nl.__class__.__name__, 'status': spec.status} if mode == 'full': ret[name]['config'] = spec.nl_kwarg return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('PUT', '/sources') def sources_restart(self): node = bottle.request.body.getvalue().decode('utf-8') self.ndb.sources[node].start() @route('POST', '/sources') def sources_add(self): data = bottle.request.body.getvalue().decode('utf-8') node, spec = make_spec(data, self.config) self.config['sources'].append(node) self.ndb.connect_source(node, spec) @route('DELETE', '/sources') def sources_del(self): node = bottle.request.body.getvalue().decode('utf-8') self.config['sources'].remove(node) self.ndb.disconnect_source(node) @route('GET', '/config') def config_get(self): return bottle.template('{{!ret}}', ret=json.dumps(self.config)) @route('PUT', '/config') def config_dump(self): path = bottle.request.body.getvalue().decode('utf-8') self.config.dump(path) @route('GET', '/<name:re:(%s|%s|%s|%s|%s|%s)>' % ('interfaces', 'addresses', 'routes', 'neighbours', 'vlans', 'bridges')) def view(self, name): ret = [] obj = getattr(self.ndb, name) for line in obj.dump(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) @route('GET', '/query/<name:re:(%s|%s|%s|%s)>' % ('nodes', 'p2p_edges', 'l2_edges', 'l3_edges')) def <|fim_middle|>(self, name): ret = [] obj = getattr(self.ndb.query, name) for line in obj(): ret.append(line) return bottle.template('{{!ret}}', ret=json.dumps(ret)) <|fim▁end|>
query
<|file_name|>utils.py<|end_file_name|><|fim▁begin|>''' utils.py: helper functions for DLP api Copyright (c) 2017 Vanessa Sochat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:<|fim▁hole|> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from som.logger import bot import os import sys def paginate_items(items,size=100): '''paginate_items will return a list of lists, each of a particular max size ''' groups = [] for idx in range(0, len(items), size): group = items[idx:idx+size] groups.append(group) return groups def clean_text(text,findings): '''clean_text will remove phi findings from a text object :param text: the original text sent to the content.inspect DLP endpoint :param findings: the full response for the text. ''' if 'findings' in findings: for finding in findings['findings']: label = "**%s**" %finding['infoType']['name'] # Note sure if this is best strategy, we can start with it text = text.replace(finding['quote'],label) return text<|fim▁end|>
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> ''' utils.py: helper functions for DLP api Copyright (c) 2017 Vanessa Sochat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from som.logger import bot import os import sys def paginate_items(items,size=100): <|fim_middle|> def clean_text(text,findings): '''clean_text will remove phi findings from a text object :param text: the original text sent to the content.inspect DLP endpoint :param findings: the full response for the text. ''' if 'findings' in findings: for finding in findings['findings']: label = "**%s**" %finding['infoType']['name'] # Note sure if this is best strategy, we can start with it text = text.replace(finding['quote'],label) return text <|fim▁end|>
'''paginate_items will return a list of lists, each of a particular max size ''' groups = [] for idx in range(0, len(items), size): group = items[idx:idx+size] groups.append(group) return groups
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> ''' utils.py: helper functions for DLP api Copyright (c) 2017 Vanessa Sochat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from som.logger import bot import os import sys def paginate_items(items,size=100): '''paginate_items will return a list of lists, each of a particular max size ''' groups = [] for idx in range(0, len(items), size): group = items[idx:idx+size] groups.append(group) return groups def clean_text(text,findings): <|fim_middle|> <|fim▁end|>
'''clean_text will remove phi findings from a text object :param text: the original text sent to the content.inspect DLP endpoint :param findings: the full response for the text. ''' if 'findings' in findings: for finding in findings['findings']: label = "**%s**" %finding['infoType']['name'] # Note sure if this is best strategy, we can start with it text = text.replace(finding['quote'],label) return text
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> ''' utils.py: helper functions for DLP api Copyright (c) 2017 Vanessa Sochat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from som.logger import bot import os import sys def paginate_items(items,size=100): '''paginate_items will return a list of lists, each of a particular max size ''' groups = [] for idx in range(0, len(items), size): group = items[idx:idx+size] groups.append(group) return groups def clean_text(text,findings): '''clean_text will remove phi findings from a text object :param text: the original text sent to the content.inspect DLP endpoint :param findings: the full response for the text. ''' if 'findings' in findings: <|fim_middle|> return text <|fim▁end|>
for finding in findings['findings']: label = "**%s**" %finding['infoType']['name'] # Note sure if this is best strategy, we can start with it text = text.replace(finding['quote'],label)
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> ''' utils.py: helper functions for DLP api Copyright (c) 2017 Vanessa Sochat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from som.logger import bot import os import sys def <|fim_middle|>(items,size=100): '''paginate_items will return a list of lists, each of a particular max size ''' groups = [] for idx in range(0, len(items), size): group = items[idx:idx+size] groups.append(group) return groups def clean_text(text,findings): '''clean_text will remove phi findings from a text object :param text: the original text sent to the content.inspect DLP endpoint :param findings: the full response for the text. ''' if 'findings' in findings: for finding in findings['findings']: label = "**%s**" %finding['infoType']['name'] # Note sure if this is best strategy, we can start with it text = text.replace(finding['quote'],label) return text <|fim▁end|>
paginate_items
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> ''' utils.py: helper functions for DLP api Copyright (c) 2017 Vanessa Sochat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' from som.logger import bot import os import sys def paginate_items(items,size=100): '''paginate_items will return a list of lists, each of a particular max size ''' groups = [] for idx in range(0, len(items), size): group = items[idx:idx+size] groups.append(group) return groups def <|fim_middle|>(text,findings): '''clean_text will remove phi findings from a text object :param text: the original text sent to the content.inspect DLP endpoint :param findings: the full response for the text. ''' if 'findings' in findings: for finding in findings['findings']: label = "**%s**" %finding['infoType']['name'] # Note sure if this is best strategy, we can start with it text = text.replace(finding['quote'],label) return text <|fim▁end|>
clean_text
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): """ Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): logging.debug("gcc missing - trying to install") sm.install('gcc') ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 logging.info('\n Test initialize successfully') def run_once(self, test_path=''): """ Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate()<|fim▁hole|> except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e) def postprocess(self): if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ')<|fim▁end|>
if ret_val.returncode != 0: self.nfail += 1
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): <|fim_middle|> <|fim▁end|>
""" Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): logging.debug("gcc missing - trying to install") sm.install('gcc') ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 logging.info('\n Test initialize successfully') def run_once(self, test_path=''): """ Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e) def postprocess(self): if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ')
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): """ Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): <|fim_middle|> def run_once(self, test_path=''): """ Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e) def postprocess(self): if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ') <|fim▁end|>
""" Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): logging.debug("gcc missing - trying to install") sm.install('gcc') ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 logging.info('\n Test initialize successfully')
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): """ Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): logging.debug("gcc missing - trying to install") sm.install('gcc') ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 logging.info('\n Test initialize successfully') def run_once(self, test_path=''): <|fim_middle|> def postprocess(self): if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ') <|fim▁end|>
""" Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e)
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): """ Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): logging.debug("gcc missing - trying to install") sm.install('gcc') ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 logging.info('\n Test initialize successfully') def run_once(self, test_path=''): """ Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e) def postprocess(self): <|fim_middle|> <|fim▁end|>
if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ')
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): """ Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): <|fim_middle|> ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 logging.info('\n Test initialize successfully') def run_once(self, test_path=''): """ Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e) def postprocess(self): if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ') <|fim▁end|>
logging.debug("gcc missing - trying to install") sm.install('gcc')
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): """ Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): logging.debug("gcc missing - trying to install") sm.install('gcc') ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: <|fim_middle|> logging.info('\n Test initialize successfully') def run_once(self, test_path=''): """ Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e) def postprocess(self): if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ') <|fim▁end|>
self.nfail += 1
<|file_name|>sblim_sfcb.py<|end_file_name|><|fim▁begin|>#!/bin/python import os, subprocess import logging from autotest.client import test from autotest.client.shared import error, software_manager sm = software_manager.SoftwareManager() class sblim_sfcb(test.test): """ Autotest module for testing basic functionality of sblim_sfcb @author Wang Tao <[email protected]> """ version = 1 nfail = 0 path = '' def initialize(self, test_path=''): """ Sets the overall failure counter for the test. """ self.nfail = 0 if not sm.check_installed('gcc'): logging.debug("gcc missing - trying to install") sm.install('gcc') ret_val = subprocess.Popen(['make', 'all'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: self.nfail += 1 logging.info('\n Test initialize successfully') def run_once(self, test_path=''): """ Trigger test run """ try: os.environ["LTPBIN"] = "%s/shared" %(test_path) ret_val = subprocess.Popen(['./sblim-sfcb-test.sh'], cwd="%s/sblim_sfcb" %(test_path)) ret_val.communicate() if ret_val.returncode != 0: <|fim_middle|> except error.CmdError, e: self.nfail += 1 logging.error("Test Failed: %s", e) def postprocess(self): if self.nfail != 0: logging.info('\n nfails is non-zero') raise error.TestError('\nTest failed') else: logging.info('\n Test completed successfully ') <|fim▁end|>
self.nfail += 1