Exemplo n.º 1
0
def test_postgresql_version(host):
    os = host.system_info.distribution
    pkg = "percona-postgresql-client-{}".format(MAJOR_VER)
    if os.lower() in ["redhat", "centos", 'rhel']:
        pkg = "percona-postgresql{}".format(MAJOR_VER)
    pkg = host.package(pkg)
    assert MAJOR_VER in pkg.version
Exemplo n.º 2
0
def test_postgresql_client_version(host):
    os = host.system_info.distribution
    pkg = "percona-postgresql-{}".format(MAJOR_VER)
    if os.lower() in ["redhat", "centos", 'rhel']:
        pytest.skip("This test only for Debian based platforms")
    pkg = host.package(pkg)
    assert MAJOR_VER in pkg.version
Exemplo n.º 3
0
def postgresql_binary(host):
    os = host.system_info.distribution
    if os.lower() in ["redhat", "centos", 'rhel']:
        return host.file("/usr/pgsql-{}/bin/postgres".format(MAJOR_VER))
    elif os in ["debian", "ubuntu"]:
        return host.file(
            "/usr/lib/postgresql/{}/bin/postgres".format(MAJOR_VER))
Exemplo n.º 4
0
def _resumeOS():
    """
    Resume stored OS information from HashDB
    """

    value = hashDBRetrieve(HASHDB_KEYS.OS)

    if not value:
        return

    os = value

    if os and os != 'None':
        infoMsg = "resuming back-end DBMS operating system '%s' " % os
        logger.info(infoMsg)

        if conf.os and conf.os.lower() != os.lower():
            message = "you provided '%s' as back-end DBMS operating " % conf.os
            message += "system, but from a past scan information on the "
            message += "target URL sqlmap assumes the back-end DBMS "
            message += "operating system is %s. " % os
            message += "Do you really want to force the back-end DBMS "
            message += "OS value? [y/N] "
            test = readInput(message, default="N")

            if not test or test[0] in ("n", "N"):
                conf.os = os
        else:
            conf.os = os

        Backend.setOs(conf.os)
Exemplo n.º 5
0
def download_frida_server(os, arch, release=None):
    """Download frida server of arch to a temporary file. Returns temporary file location.

    Args:
        os (str): What OS to download, i.e.: ios, android, linux, windows, macos
        arch (str): What arch to download, i.e.: x86, x86_64, arm, arm64
        release (str, optional): What release to download (default to latest)
            Example: 12.6.11
    
    Examples:
        download_frida_server('android', 'x86_64')
        download_frida_server('android', 'arm')
    """

    os = os.lower()
    arch = arch.lower()
    valid_os = ['android', 'ios', 'windows', 'macos']
    valid_arch = ['arm64', 'x86_64', 'x86', 'arm']

    assert os in valid_os, "Invalid OS selected. Must be in: " + str(valid_os)
    assert arch in valid_arch, "Invalid arch selected. Must be in: " + str(
        valid_arch)

    if release is None:
        download_url = "https://github.com/frida/frida/releases/latest"
    else:
        download_url = "https://github.com/frida/frida/releases/tag/" + release

    r = requests.get(download_url)
    html = bs4.BeautifulSoup(r.text, features="html.parser")
    download_links = set(
        [x['href'] for x in html("a") if 'download' in x['href']])
    server_download_links = set(
        [x for x in download_links if "frida-server" in x])

    look_for = "{os}-{arch}.".format(os=os, arch=arch)
    server_download_link = [x for x in server_download_links if look_for in x]

    if server_download_link == []:
        error = "Couldn't find a download link for {} {}!".format(os, arch)
        logger.error(error)
        raise Exception(error)

    if len(server_download_link) > 1:
        error = "Found multiple download links for {} {}!".format(os, arch)
        logger.error(error)
        raise Exception(error)

    server_download_link = "https://github.com" + server_download_link[0]
    print("Downloading " + server_download_link, flush=True)
    r = requests.get(server_download_link)
    server_bin = lzma.decompress(r.content)

    with tempfile.NamedTemporaryFile(delete=False) as fp:
        file_name = fp.name
        fp.write(server_bin)

    logger.debug("Server downloaded to: " + file_name)

    return file_name
Exemplo n.º 6
0
def __resumeOS():
    """
    Resume stored OS information from HashDB
    """

    value = hashDBRetrieve(HASHDB_KEYS.OS)

    if not value:
        return

    os = value

    if os and os != 'None':
        infoMsg = "resuming back-end DBMS operating system '%s' " % os
        logger.info(infoMsg)

        if conf.os and conf.os.lower() != os.lower():
            message = "you provided '%s' as back-end DBMS operating " % conf.os
            message += "system, but from a past scan information on the "
            message += "target URL sqlmap assumes the back-end DBMS "
            message += "operating system is %s. " % os
            message += "Do you really want to force the back-end DBMS "
            message += "OS value? [y/N] "
            test = readInput(message, default="N")

            if not test or test[0] in ("n", "N"):
                conf.os = os
        else:
            conf.os = os

        Backend.setOs(conf.os)
Exemplo n.º 7
0
def test_postgresql_is_running_and_enabled(host):
    os = host.system_info.distribution
    if os.lower() in ["redhat", "centos", 'rhel']:
        postgresql = host.service("postgresql-{}".format(MAJOR_VER))
    else:
        postgresql = host.service("postgresql")
    assert postgresql.is_running
Exemplo n.º 8
0
 def connect_thread(self):
     try:
         if self.auth.is_rsa():
             self.client.connect(self.server.host, self.server.port, self.auth.login, key_filename=self.auth.get_rsa_files(), timeout=25)
         else:
             self.client.connect(self.server.host, self.server.port, self.auth.login, self.auth.password, timeout=25)
         self.isConnected = self.client.get_transport().is_active()
         
         if(self.isConnected):
             self.client.get_transport().set_keepalive(300)
         
         hostname, os = self.sendCommand('hostname && uname').split()
         self.server.set_hostname(hostname)
         self.server.set_os(os.lower())
         
         # Emits signal that server is connected
         self.emit(QtCore.SIGNAL('connected'), self)
         
         return True
     
     except:
         # Emits signal that server is connected
         self.emit_notconnected()
         #self.emit(QtCore.SIGNAL('notConnected'), self)
         
         print 'Unable to connect to %s:%s with login %s, pass %s' % (self.server.host, self.server.port, self.auth.login, self.auth.password)
         QtCore.QCoreApplication.processEvents();
         
         try:
             self.client.close()
         except:
             pass
         return False
Exemplo n.º 9
0
def test_deb_package_is_installed(host, package):
    os = host.system_info.distribution
    if os.lower() in ["redhat", "centos", 'rhel']:
        pytest.skip("This test only for Debian based platforms")
    pkg = host.package(package)
    assert pkg.is_installed
    assert pkg.version in pg_versions['deb_pkg_ver']
Exemplo n.º 10
0
def get_asset_type(os):
    os = os.lower()
    if "centos" in os:
        return "CentOS"
    elif "red hat" in os:
        return "Red Hat"
    elif "ubuntu" in os:
        return "Ubuntu"
    elif "debian" in os:
        return "Debian"
    elif "amazon linux" in os:
        return "Amazon Linux"
    elif "oracle linux" in os:
        return "Oracle Linux"
    elif "freebsd" in os:
        return "FreeBSD"
    elif "openbsd" in os:
        return "OpenBSD"
    elif "suse" in os:
        return "Suse"
    elif "mac os" in os or "macos" in os:
        return "Mac OS"
    elif "windows" in os:
        return "Windows"
    elif "alpine" in os:
        return "Alpine Linux"
    else:
        logging.error("Not a supported OS type [%s]" % os)
        return None
Exemplo n.º 11
0
    def setUp(self, s_browsers, s_userid, s_apikey, b_video, b_screenshot,
              s_testname):
        self.s_browsers = s_browsers
        self.s_userid = s_userid
        self.s_apikey = s_apikey
        self.s_testname = s_testname
        self.b_video = b_video
        self.b_screenshot = b_screenshot
        browser, version, os = self.s_browsers.split('-')

        desired_capabilities = SAUCEBROWSER[browser.lower()].copy()
        desired_capabilities['version'] = version if version.lower(
        ) != 'latest' else ''
        desired_capabilities['platform'] = SAUCEOS[os.lower()]
        desired_capabilities['name'] = self.s_testname
        desired_capabilities['record-video'] = self.b_video
        desired_capabilities['record-screenshots'] = self.b_screenshot
        self.driver = webdriver.Remote(
            desired_capabilities=desired_capabilities,
            command_executor="http://{user}:{key}@{host}:{port}/wd/hub".format(
                user=self.s_userid,
                key=self.s_apikey,
                host="ondemand.saucelabs.com",
                port="80"))
        self.driver.implicitly_wait(30)
Exemplo n.º 12
0
    def __init__(self, product, platform, os, version=None, env=None, args=None, metadata=None):
        '''
        @type product: string
        @param product: The name of the product/program/branch tested
        @type platform: string
        @param platform: Platform on which is tested (e.g. x86, x86-64 or arm)
        @type os: string
        @param os: Operating system on which is tested (e.g. linux, windows, macosx)
        '''
        self.product = product.lower()
        self.platform = platform.lower()
        self.os = os.lower()
        self.version = version

        if env is None:
            env = {}

        if args is None:
            args = []

        if metadata is None:
            metadata = {}

        assert isinstance(env, dict)
        assert isinstance(args, list)
        assert isinstance(metadata, dict)

        self.env = env
        self.args = args
        self.metadata = metadata
Exemplo n.º 13
0
def dirty_cow(os, os_version, kernel_version):
    """
    Compares the current version to the vulnerable ones and returns
    True if vulnerable, False if safe, None if not matched with
    anything.
    """
    min_patched_version = "3.2.0"

    vulnerables = {
        "ubuntu": {
            "16.10": "4.8.0-26.28",
            "16.04": "4.4.0-45.66",
            "14.04": "3.13.0-100.147",
            "12.04": "3.2.0-113.155"
        },
        "debian": {
            "7": "3.2.82-1",
            "8": "3.16.36-1+deb8u2"
        },
        "centos": {
            "6": "3.10.58-rt62.60.el6rt",
            "7": "3.10.0-327.36.1.rt56.237.el7"
        },
        "rhel": {
            "6": "3.10.58-rt62.60.el6rt",
            "6.8": "3.10.58-rt62.60.el6rt",
            "7": "3.10.0-327.36.1.rt56.237.el7",
            "7.2": "3.10.0-327.36.1.rt56.237.el7"
        },
    }

    # If version is lower that min_patched_version it is most probably vulnerable
    if LooseVersion(kernel_version) < LooseVersion(min_patched_version):
        return True

    # If version is greater/equal to 4.9 it is patched
    if LooseVersion(kernel_version) >= LooseVersion('4.9.0'):
        return False

    os = os.lower()

    # In case of CoreOS, where we have no discrete VERSION_ID
    if os == 'coreos':
        if LooseVersion(kernel_version) <= LooseVersion('4.7.0'):
            return True
        else:
            return False

    if os not in vulnerables.keys():
        return None

    if os_version not in vulnerables[os].keys():
        return None

    vuln_version = vulnerables[os][os_version]
    if LooseVersion(kernel_version) <= LooseVersion(vuln_version):
        return True
    else:
        return False
Exemplo n.º 14
0
def pgrepack(host):
    os = host.system_info.distribution
    if os.lower() in ["redhat", "centos", 'rhel']:
        cmd = "/usr/pgsql-{}/bin/pg_repack ".format(MAJOR_VER)
    else:
        # TODO need to be in PATH?
        cmd = "/usr/lib/postgresql/{}/bin/pg_repack".format(MAJOR_VER)
    return host.check_output(cmd)
Exemplo n.º 15
0
def test_postgresql_is_running_and_enabled(host):
    os = host.system_info.distribution
    service_name = "postgresql"
    if os.lower() in ["redhat", "centos", 'rhel']:
        service_name = f"postgresql-{MAJOR_VER}"
    service = host.service(service_name)
    assert service.is_running
    assert service.is_enabled
Exemplo n.º 16
0
    def os(self, os):

        os = os.lower()

        if os not in ContextType.oses:
            raise AttributeError("os must be one of %r" % ContextType.oses)

        return os
Exemplo n.º 17
0
def pgrepack(host):
    os = host.system_info.distribution
    if os.lower() in ["redhat", "centos", 'rhel']:
        cmd = "file /usr/pgsql-11/bin/pg_repack "
    else:
        # TODO need to be in PATH?
        cmd = "file /usr/lib/postgresql/11/bin/pg_repack"
    return host.check_output(cmd)
Exemplo n.º 18
0
Arquivo: oss.py Projeto: zhuhaow/conan
def get_gnu_triplet(os, arch, compiler=None):
    """
    Returns string with <machine>-<vendor>-<op_system> triplet (<vendor> can be omitted in practice)

    :param os: os to be used to create the triplet
    :param arch: arch to be used to create the triplet
    :param compiler: compiler used to create the triplet (only needed fo windows)
    """

    if os == "Windows" and compiler is None:
        raise ConanException(
            "'compiler' parameter for 'get_gnu_triplet()' is not specified and "
            "needed for os=Windows")

    # Calculate the arch
    machine = {
        "x86": "i686" if os != "Linux" else "x86",
        "x86_64": "x86_64",
        "armv6": "arm",
        "armv7": "arm",
        "armv7s": "arm",
        "armv7k": "arm",
        "armv7hf": "arm",
        "armv8": "aarch64"
    }.get(arch, None)
    if machine is None:
        raise ConanException(
            "Unknown '%s' machine, Conan doesn't know how to "
            "translate it to the GNU triplet, please report at "
            " https://github.com/conan-io/conan/issues" % arch)

    # Calculate the OS
    if compiler == "gcc":
        windows_op = "w64-mingw32"
    elif compiler == "Visual Studio":
        windows_op = "windows-msvc"
    else:
        windows_op = "windows"

    op_system = {
        "Windows": windows_op,
        "Linux": "linux-gnu",
        "Darwin": "apple-darwin",
        "Android": "linux-android",
        "Macos": "apple-darwin",
        "iOS": "apple-darwin",
        "watchOS": "apple-darwin",
        "tvOS": "apple-darwin"
    }.get(os, os.lower())

    if os in ("Linux", "Android"):
        if "arm" in arch and arch != "armv8":
            op_system += "eabi"

        if arch == "armv7hf" and os == "Linux":
            op_system += "hf"

    return "%s-%s" % (machine, op_system)
Exemplo n.º 19
0
    def __check_os(self):

        os = self.support_vectors.get('os').execute()
        if 'win' in os.lower():
            os = 'win'
        else:
            os = 'Linux'
            
        self._result['os'] = [ os ]
Exemplo n.º 20
0
def getOS(architecture=False, removeLinux=False):
    os = distro.linux_distribution()[0]
    if removeLinux:
        os = re.sub('linux', '', os, flags=re.IGNORECASE)
    os = os.rstrip()
    if architecture:
        os += ' ' + platform.machine()
    os = os.lower()
    return os
Exemplo n.º 21
0
 def _get_system_from_os(os: str) -> str:
     """
     Converts from `conan/conans/client/conf/__init__.py` to `https://mesonbuild.com/Reference-tables.html#operating-system-names`
     """
     os = os.lower()
     if (os == 'macos' or os == 'ios'):
         return 'darwin'
     else:
         return os
Exemplo n.º 22
0
def test_deb_files(host, file):
    os = host.system_info.distribution
    if os.lower() in ["redhat", "centos", 'rhel']:
        pytest.skip("This test only for Debian based platforms")
    with host.sudo("postgres"):
        f = host.file(file)
        assert f.exists
        assert f.size > 0
        assert f.content_string != ""
        assert f.user == "postgres"
Exemplo n.º 23
0
def this_characteristic_nothere(true_or_false,dict_defined,system,os_string,filter_name):
	counter = 0
	if true_or_false:
		for os in dict_defined:
			if os.lower() in os_string:
				counter += 1
		if counter == 0:
			if debug: print "%s has been skipped b/c of %s filtering" % (system,filter_name)
			return True
	return False
Exemplo n.º 24
0
 def checkOS(self):
     """ Method to check the os where the script is running
         Arguments:
             self (Pssch): self instance
     """
     os = platform.system()
     if os == 'Linux' or os == 'Windows':
         return os.lower()
     else:
         return 'osx'
Exemplo n.º 25
0
def checkForNewerVersion():
	try:
		releaseData = getCuraVersionXMLTree()
	except:
		releaseData = None
		
	if releaseData != None:
		latestReleaseDict = {}
	
		downloadLink = ''
		latestVersion = ''
		# When parsing xml file:
		# 	- .tag gets the name of the element i.e., <elementName>
		# 	- .text gets the data stored within that element
		if releaseData: 
			for release in releaseData:	
				os = str(release.attrib['os'])

				if sys.platform.lower() == os.lower():
					latestReleaseDict = {
						"major": int(release.attrib['major']),
						"minor": int(release.attrib['minor']),
						"patch": str(release.attrib['patch']),
						"preReleaseType": str(release.attrib['preReleaseType']),
						"preReleaseVersion": str(release.attrib['preReleaseVersion'])
					}
					# file name and version
					for item in release:
						if item.tag == 'filename':
							downloadLink = item.text
						if item.tag == 'version':
							latestVersion = item.text
						
			thisVersion = getVersion()
			
			# "arbitrary" version number
			if thisVersion == 'dev':
				thisVersion = '1.5.0b0'
				
			updateStatusDict = {"needsUpdate" : '',
													"downloadLink" : '',
													"updateVersion" : ''
													}

			thisVersionDict = getThisVersionDataForComparison(thisVersion)
			needsUpdate = compareLocalToLatest(thisVersionDict, latestReleaseDict)
			updateStatusDict['needsUpdate'] = needsUpdate	

			if needsUpdate == True:
				updateStatusDict['downloadLink'] = downloadLink
				updateStatusDict['updateVersion'] = latestVersion

			return updateStatusDict
	else:
		return None
Exemplo n.º 26
0
def vulnerable_packages(os, version):
    '''
    Get the list of vulnerabilities as declared in the os-specific
    variable file
    '''
    with open("../../vars/%s%s.yml" % (os.lower(), version)) as stream:
        try:
            vars = (yaml.safe_load(stream))['security_updates']
            return vars
        except yaml.YAMLError as exc:
            print(exc)
Exemplo n.º 27
0
 def getOperatingSystem(self):
     #detecting the operating system using `os.name` System property
     os = java.lang.System.getProperty("os.name")
     os = os.lower()
     if "win" in os:
         return "WINDOWS"
     elif "nix" in os or "nux" in os or "aix" in os:
         return "LINUX"
     elif "mac" in os:
         return "MAC"
     return None
Exemplo n.º 28
0
 def match_os(self, os):
     # If you have lots of big scans in your DB (with a lot of hosts scanned),
     # you're probably better off using the keyword (freetext) search. Keyword
     # search just greps through the nmap output, while this function iterates
     # through all parsed OS-related values for every host in every scan!
     hosts = self.parsed_scan.get_hosts()
     os = os.lower()
     for host in hosts:
         if HostSearch.match_os(host, os):
             return True
     return False
Exemplo n.º 29
0
def test_bats_with_numactl(host):
    with host.sudo():
        os = host.system_info.distribution
        cmd = 'apt-get install numactl -y'
        if os.lower() in ["redhat", "centos", 'rhel']:
            cmd = 'yum install numactl -y'
        result = host.run(cmd)
        assert result.rc == 0, result.stdout
        cmd = "/usr/local/bin/bats /package-testing/bats/mongo-init-scripts.bats"
        result = host.run(cmd)
    assert result.rc == 0, result.stdout
Exemplo n.º 30
0
def normalise_os(os):
    """ recognise os name using aliases known to cabal """
    os = os.lower()
    if os in ["mingw32", "win32", "cygwin32"]: return "windows"
    if os == "darwin": return "osx"
    if os == "gnu": return "hurd"
    if os == "kfreebsdgnu": return "freebsd"
    if os == "solaris2": return "solaris"
    if os in ["linux-android", "linux-androideabi", "linux-androideabihf"]:
        return "android"
    return os
Exemplo n.º 31
0
def convert_os(os):
    conversions = {'centos': 'CentOS',
                   'debian': 'Debian',
                   'fedora': 'Fedora',
                   'opensuse': 'OpenSuSE',
                   'redhat': 'RedHat',
                   'sles': 'SLES',
                   'ubuntu': 'Ubuntu',
                   'windows': 'Windows',
                   'other': 'Other'}
    return conversions.get(os.lower(), "Other")
Exemplo n.º 32
0
 def match_os(self, os):
     # If you have lots of big scans in your DB (with a lot of hosts scanned),
     # you're probably better off using the keyword (freetext) search. Keyword
     # search just greps through the nmap output, while this function iterates
     # through all parsed OS-related values for every host in every scan!
     hosts = self.parsed_scan.get_hosts()
     os = os.lower()
     for host in hosts:
         if HostSearch.match_os(host, os):
             return True
     return False
Exemplo n.º 33
0
def pgaudit(host):
    os = host.system_info.distribution
    with host.sudo("postgres"):
        enable_library = "psql -c \'ALTER SYSTEM SET shared_preload_libraries=\'pgaudit\'\';"
        result = host.check_output(enable_library)
        assert result.strip("\n") == "ALTER SYSTEM"
        enable_pgaudit = "psql -c 'CREATE EXTENSION pgaudit;'"
        result = host.check_output(enable_pgaudit)
        assert result.strip("\n") == "CREATE EXTENSION"
        cmd = """
        psql -c \"SELECT setting FROM pg_settings WHERE name='shared_preload_libraries';\" | awk 'NR==3{print $1}'
        """
        result = host.check_output(cmd)
        assert result.strip("\n") == "pgaudit"
        enable_ddl = """psql -c \"ALTER SYSTEM SET pgaudit.log = 'all';\""""
        result = host.check_output(enable_ddl)
        assert result.strip("\n") == "ALTER SYSTEM"
        reload_conf = "psql -c 'SELECT pg_reload_conf();'"
        result = host.run(reload_conf)
        assert result.rc == 0
        create_table = "psql -c \"CREATE TABLE t1 (id int,name varchar(30));\""
        result = host.run(create_table)
        assert result.rc == 0
        assert result.stdout.strip("\n") == "CREATE TABLE"
        log_file = "/var/log/postgresql/postgresql-11-main.log"
        if os.lower() in ["debian", "ubuntu"]:
            log_file = "/var/log/postgresql/postgresql-11-main.log"
        elif os.lower() in ["redhat", "centos", 'rhel']:
            log_files = "ls /var/lib/pgsql/11/data/log/"
            file_name = host.check_output(log_files).strip("\n")
            log_file = "".join(["/var/lib/pgsql/11/data/log/", file_name])
        file = host.file(log_file)
        file_content = file.content_string
    yield file_content
    with host.sudo("postgres"):
        drop_pgaudit = "psql -c 'DROP EXTENSION pgaudit;'"
        result = host.check_output(drop_pgaudit)
        assert result.strip("\n") == "DROP EXTENSION"
    cmd = "sudo systemctl restart postgresql"
    result = host.run(cmd)
    assert result.rc == 0
Exemplo n.º 34
0
def test_deb_packages_provides(host, percona_package, vanila_package):
    """Execute command for check provides and check that we have link to vanila postgres
    """
    os = host.system_info.distribution
    if os.lower() in ["redhat", "centos", 'rhel']:
        pytest.skip("This test only for Debs.ian based platforms")
    cmd = "dpkg -s {} | grep Provides".format(percona_package)
    result = host.run(cmd)
    provides = set(result.stdout.split())
    provides = {provide.strip(",") for provide in provides}
    assert result.rc == 0, result.stdout
    assert vanila_package in provides, provides
Exemplo n.º 35
0
def test_language(host, language):
    os = host.system_info.distribution
    with host.sudo("postgres"):
        if os.lower() in ["redhat", "centos", 'rhel']:
            if "python3" in language:
                pytest.skip("Skipping python3 language for Centos or RHEL")
        lang = host.run("psql -c 'CREATE LANGUAGE {};'".format(language))
        assert lang.rc == 0, lang.stderr
        assert lang.stdout.strip("\n") == "CREATE LANGUAGE", lang.stdout
        drop_lang = host.run("psql -c 'DROP LANGUAGE {};'".format(language))
        assert drop_lang.rc == 0, drop_lang.stderr
        assert drop_lang.stdout.strip("\n") == "DROP LANGUAGE", lang.stdout
Exemplo n.º 36
0
def test_patroni_package(host):
    os = host.system_info.distribution
    pkgn = ""
    if os.lower() in ["ubuntu", "redhat", "centos", 'rhel']:
        pkgn = "percona-patroni"
    elif os == "debian":
        pkgn = "percona-patroni"
    if pkgn == "":
        pytest.fail("Unsupported operating system")
    pkg = host.package(pkgn)
    assert pkg.is_installed
    assert pg_versions['patroni']['version'] in pkg.version
Exemplo n.º 37
0
def get_gnu_triplet(os, arch, compiler=None):
    """
    Returns string with <machine>-<vendor>-<op_system> triplet (<vendor> can be omitted in practice)

    :param os: os to be used to create the triplet
    :param arch: arch to be used to create the triplet
    :param compiler: compiler used to create the triplet (only needed fo windows)
    """

    if os == "Windows" and compiler is None:
        raise ConanException("'compiler' parameter for 'get_gnu_triplet()' is not specified and "
                             "needed for os=Windows")

    # Calculate the arch
    machine = {"x86": "i686" if os != "Linux" else "x86",
               "x86_64": "x86_64",
               "armv6": "arm",
               "armv7": "arm",
               "armv7s": "arm",
               "armv7k": "arm",
               "armv7hf": "arm",
               "armv8": "aarch64"}.get(arch, None)
    if machine is None:
        raise ConanException("Unknown '%s' machine, Conan doesn't know how to "
                             "translate it to the GNU triplet, please report at "
                             " https://github.com/conan-io/conan/issues" % arch)

    # Calculate the OS
    if compiler == "gcc":
        windows_op = "w64-mingw32"
    elif compiler == "Visual Studio":
        windows_op = "windows-msvc"
    else:
        windows_op = "windows"

    op_system = {"Windows": windows_op,
                 "Linux": "linux-gnu",
                 "Darwin": "apple-darwin",
                 "Android": "linux-android",
                 "Macos": "apple-darwin",
                 "iOS": "apple-darwin",
                 "watchOS": "apple-darwin",
                 "tvOS": "apple-darwin"}.get(os, os.lower())

    if os in ("Linux", "Android"):
        if "arm" in arch and arch != "armv8":
            op_system += "eabi"

        if arch == "armv7hf" and os == "Linux":
            op_system += "hf"

    return "%s-%s" % (machine, op_system)
Exemplo n.º 38
0
 def decide_icon(os):
     """Decides the correct Pixbuf icon for a OS. None if OS not
     found or not recognized.
     """
     os = os.lower()
     if "linux" in os or "unix" in os:
         icon = GdkPixbuf.Pixbuf.new_from_file(self.linux_icon)
     elif "windows" in os:
         icon =  GdkPixbuf.Pixbuf.new_from_file(self.windows_icon)
     elif "mac" in os:
         icon =  GdkPixbuf.Pixbuf.new_from_file(self.mac_icon)
     else:
         icon = None
     return icon
Exemplo n.º 39
0
    def match_os(host, os):
        os = os.lower()
        os_str = ""

        osmatches = host.get_osmatches()

        for osmatch in osmatches:
            os_str += osmatch["name"].lower()
            for osclass in osmatch["osclasses"]:
                os_str += osclass["vendor"].lower() + " " + osclass["osfamily"].lower() + " " + osclass["type"].lower()

        if os in os_str:
            return True
        return False
Exemplo n.º 40
0
    def match_os(host, os):
        os = os.lower()

        osmatches = host.get_osmatches()

        for osmatch in osmatches:
            os_str = osmatch['name'].lower()
            for osclass in osmatch['osclasses']:
                os_str += " " + osclass['vendor'].lower() + " " +\
                          osclass['osfamily'].lower() + " " +\
                          osclass['type'].lower()
            if os in os_str:
                return True

        return False
Exemplo n.º 41
0
    def _create_local_site(self):
        """
        Create a local site for the workflow
        """
        os = platform.system()
        if os.lower() == 'linux':
            os = OSType.LINUX
        elif os.lower() == 'windows':
            os = OSType.WINDOWS
        else:
            os = OSType.MACOSX

        # create local site
        self._sites = self._create_site('local', platform.machine(), os)
        self._sites['local']['directories'] = {
            DirectoryType.SHARED_SCRATCH:
                {
                    'path': self.workflow_dir + '/scratch'
                },
            DirectoryType.SHARED_STORAGE:
                {
                    'path': self.workflow_dir + '/output'
                }
        }
Exemplo n.º 42
0
 def setUp(self,s_browsers,s_userid,s_apikey,b_video,b_screenshot,s_testname):
   self.s_browsers = s_browsers
   self.s_userid = s_userid
   self.s_apikey = s_apikey
   self.s_testname = s_testname
   self.b_video = b_video
   self.b_screenshot = b_screenshot
   browser, version, os = self.s_browsers.split('-')
        
   desired_capabilities = SAUCEBROWSER[browser.lower()].copy()
   desired_capabilities['version'] = version if version.lower() != 'latest' else ''
   desired_capabilities['platform'] = SAUCEOS[os.lower()]
   desired_capabilities['name'] = self.s_testname
   desired_capabilities['record-video'] = self.b_video
   desired_capabilities['record-screenshots'] = self.b_screenshot
   self.driver = webdriver.Remote(desired_capabilities = desired_capabilities,command_executor = "http://{user}:{key}@{host}:{port}/wd/hub".format(user=self.s_userid, key=self.s_apikey, host="ondemand.saucelabs.com", port="80"))
   self.driver.implicitly_wait(30)
Exemplo n.º 43
0
 def __decide_icon(self, os):
     """Return the GdkPixbuf icon according to 'os' paramather string
     and a str_id to that GdkPixbuf for easy comparison and ordering
     of the view ('os' paramether string is complicated and has caps).
     """
     os = os.lower() if os else ""
     if "linux" in os or "unix" in os:
         icon = GdkPixbuf.Pixbuf.new_from_file(self.linux_icon)
         str_id = "linux"
     elif "windows" in os:
         icon = GdkPixbuf.Pixbuf.new_from_file(self.windows_icon)
         str_id = "windows"
     elif "mac" in os:
         icon = GdkPixbuf.Pixbuf.new_from_file(self.mac_icon)
         str_id = "mac"
     else:
         icon = GdkPixbuf.Pixbuf.new_from_file(self.no_os_icon)
         str_id = "unknown"
     return icon, str_id
Exemplo n.º 44
0
    def os(self, os):
        """
        Operating system of the target machine.

        The default value is ``linux``.

        Allowed values are listed in :attr:`pwnlib.context.ContextType.oses`.

        Examples:

            >>> context.os = 'linux'
            >>> context.os = 'foobar' #doctest: +ELLIPSIS
            Traceback (most recent call last):
            ...
            AttributeError: os must be one of ['android', 'cgc', 'freebsd', 'linux', 'windows']
        """
        os = os.lower()

        if os not in ContextType.oses:
            raise AttributeError("os must be one of %r" % ContextType.oses)

        return os
Exemplo n.º 45
0
	def get_additional_value(self, attr_name, product, data, category_url):
		
		category_name = self.db.category.find_one({"_id":product["category_id"]})["name"]

		if attr_name == "Display Size":
			product_name = product['product_name'].split(' ')

			if "inches" in product_name:
				value = float(product_name[product_name.index("inches")-1])
				return value

		elif attr_name == "Headphone Type":
			type_name = ['In ear', 'On ear', 'Over ear']
			
			for elem in type_name:
				if elem in category_name:
					return elem

		elif attr_name == "Connectivity":
			product_name = product["product_name"]
			type_name = ['Wireless', 'Bluetooth']
			
			for elem in type_name:
				if elem in product_name:
					return "Wireless"
			return "Wired"

		elif attr_name == "Megapixel":

			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'Camera' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['Camera'].keys() and 'camera_primary_resolution' in data['attributesMap']['groups']['Camera']['attributes'].keys():				
				return data['attributesMap']['groups']['Camera']['attributes']['camera_primary_resolution']['value']

		elif attr_name == "Screen Size":
			
			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'Camera' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['Camera'].keys() and 'screen_size_text' in data['attributesMap']['groups']['Camera']['attributes'].keys():	
							
				return data['attributesMap']['groups']['Camera']['attributes']['screen_size_text']['value'].split(" ")[0] + " Inch"

			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'Display' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['Display'].keys() and 'screen_size_text' in data['attributesMap']['groups']['Display']['attributes'].keys() and 'value' in data['attributesMap']['groups']['Display']['attributes']['screen_size_text'].keys():
				return data['attributesMap']['groups']['Display']['attributes']['screen_size_text']['value'].split(" ")[0] + " Inch"

		elif attr_name == "Type" or attr_name == "Accessory Type":
			
			if category_name == "Mobile Phones":
				if "smartphones" in category_url:
					return "Smartphone"
				elif "basic_phones" in category_url:
					return "Basic Phone"

			if 'highlights' in data.keys():				
				for elem in data['highlights']:
					temp = elem.split(":")				
					if temp[0].strip() == "Type":
						return temp[1].strip()

		elif category_name == "Mobile Phones" and attr_name == "Operating System":
			if "basic_phones" in category_url:
				return "Native"
			else:
				
				if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'General Features' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['General Features'].keys() and 'operating_system' in data['attributesMap']['groups']['General Features']['attributes'].keys() and 'value' in data['attributesMap']['groups']['General Features']['attributes']['operating_system'].keys():
					os = data['attributesMap']['groups']['General Features']['attributes']['operating_system']['value']
					
					if 'ios' in os.lower():
						return "iOS"
					elif 'blackberry' in os.lower():
						return "Blackberry OS"
					elif 'window' in os.lower():
						return "Windows"
					else:
						return os

		elif attr_name == "Storage Capacity":
			
			if "https://en-ae.wadi.com/electronics-mobiles_tablets-tablets/" in category_url:
				memory = "memory_internal_dropdown"
			else:
				memory = "hard_disk_capacity_text"

			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'Memory and Storage' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['Memory and Storage'].keys() and memory in data['attributesMap']['groups']['Memory and Storage']['attributes'].keys() and 'value' in data['attributesMap']['groups']['Memory and Storage']['attributes'][memory].keys():
				if "https://en-ae.wadi.com/electronics-mobiles_tablets-tablets/" in category_url:
					return str(data['attributesMap']['groups']['Memory and Storage']['attributes'][memory]['value'])
				else:
					return str(data['attributesMap']['groups']['Memory and Storage']['attributes'][memory]['value']) + " GB"

		elif attr_name == "RAM":
			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'Memory and Storage' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['Memory and Storage'].keys() and 'ram_size_text' in data['attributesMap']['groups']['Memory and Storage']['attributes'].keys() and 'value' in data['attributesMap']['groups']['Memory and Storage']['attributes']['ram_size_text'].keys():
				return str(data['attributesMap']['groups']['Memory and Storage']['attributes']['ram_size_text']['value']) + " GB"

		elif attr_name == "Processor Type":
			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'Processor' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['Processor'].keys() and 'processor_type' in data['attributesMap']['groups']['Processor']['attributes'].keys() and 'value' in data['attributesMap']['groups']['Processor']['attributes']['processor_type'].keys():
				return data['attributesMap']['groups']['Processor']['attributes']['processor_type']['value']

		elif attr_name == "Operating System Type" or attr_name == "Operating System":
			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'Platform' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['Platform'].keys() and 'operating_system' in data['attributesMap']['groups']['Platform']['attributes'].keys() and 'value' in data['attributesMap']['groups']['Platform']['attributes']['operating_system'].keys():
				os = data['attributesMap']['groups']['Platform']['attributes']['operating_system']['value'].lower()
				
				if "window" in os or "windows" in os or "win" in os:
					return "Windows"
				elif "mac" in os:
					return "Mac OS"
				elif "chrome" in os:
					return "Chrome"
				elif "Android" in os:
					return "Android"
				else:
					return "Linux"

		elif attr_name == "Color":
			if "attributes" in data.keys() and 'color_family_en' in data['attributes'].keys():
				return data['attributes']['color_family_en']

		elif attr_name == "Platform":
			if 'attributesMap' in data.keys() and 'groups' in data['attributesMap'].keys() and 'General Features' in data['attributesMap']['groups'].keys() and 'attributes' in data['attributesMap']['groups']['General Features'].keys() and 'gaming_platform' in data['attributesMap']['groups']['General Features']['attributes'].keys() and 'value' in data['attributesMap']['groups']['General Features']['attributes']['gaming_platform'].keys():
				return data['attributesMap']['groups']['General Features']['attributes']['gaming_platform']['value']

		elif attr_name == "Mobile Accessory Type":
			return "Covers"

		return ''
    def expand_macro(self, formatter, name, args):
        global mode, release

        args, kw = parse_args(args)
        if 'release' in kw: release = kw['release']
        self.version = kw['version']

        if 'project' in kw: projects = [kw['project']]
        else: projects = kw['projects'].split(':')

        if 'mode' in kw: mode = kw['mode']
        else: mode = 'release'
        if 'exts' in kw: self.exts = filter(lambda x: x, kw['exts'].split(':'))
        else: self.exts = default_exts

        img_url = formatter.href.base + '/chrome/site/images'

        result = ''

        for desc, oses, builds in packages:
            items = []

            for project in projects:
                for build in builds:
                    items += self.do_release(build, project)

            if not len(items): continue

            # Find latest version
            max_version = (0, 0, 0)
            for item in items:
                if max_version < item[2]: max_version = item[2]

            # Filter out all but the latest version
            items = filter(lambda item: item[2] == max_version, items)

            # Find architectures
            archs = []
            for item in items:
                if not item[4] in archs: archs.append(item[4])

            result += '<div class="build">'
            desc %= {'os': ' / '.join(oses)}
            result += '<span class="build-desc">%s</span>' % desc
            for os in reversed(oses):
                result += '<div class="build-logo">'
                result += '<img src="%s/%s-%d.png"/>' % (
                    img_url, os.lower(), logo_size)
                result += '</div>'

            # Create links ordered by architecture
            for current_arch in archs:
                if 1 < len(archs):
                    result += '<div class="build-arch">%s:</div>' % (
                        current_arch)

                result += '<ul>'
                for url, filename, version, project, arch in items:
                    if current_arch == arch:
                        result += ('<li><a href="%s">%s</a></li>' % (
                                url, filename))
                result += '</ul>'

            result += '</div>'

        return result
Exemplo n.º 47
0
def get_dist():
    """Returns the operating system related information"""

    os, version, release = platform.linux_distribution()
    return (os.lower().strip(), version, release.lower().strip())