コード例 #1
0
def Main():
    paramkeyShowSharedLib = "Show shared libraries"
    paramkeyShowFontFiles = "Show font files"

    cgiEnv = lib_common.CgiEnv(parameters={
        paramkeyShowSharedLib: False,
        paramkeyShowFontFiles: False
    })
    top_pid = int(cgiEnv.GetId())

    flagShowSharedLib = bool(cgiEnv.GetParameters(paramkeyShowSharedLib))
    flagShowFontFiles = bool(cgiEnv.GetParameters(paramkeyShowFontFiles))

    grph = cgiEnv.GetGraph()

    proc_obj = CIM_Process.PsutilGetProcObj(top_pid)

    # sys.stderr.write("top_pid=%d\n" % top_pid)

    node_process = lib_common.gUriGen.PidUri(top_pid)
    CIM_Process.AddInfo(grph, node_process, [str(top_pid)])

    ################################################################################

    try:
        fillist = CIM_Process.PsutilProcOpenFiles(proc_obj)
    except Exception:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught:" + str(exc) + ":" + str(proc_obj))

    for fil in fillist:
        # TODO: Resolve symbolic links. Do not do that if shared memory.
        # TODO: AVOIDS THESE TESTS FOR SHARED MEMORY !!!!
        if lib_common.MeaninglessFile(fil.path, not flagShowSharedLib,
                                      not flagShowFontFiles):
            continue

        fileNode = lib_common.gUriGen.FileUri(fil.path)
        grph.add((node_process, pc.property_open_file, fileNode))

    # This works but not really necessary because there are not so many files.
    # cgiEnv.OutCgiRdf( "", [pc.property_open_file] )
    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
コード例 #2
0
ファイル: search_urls.py プロジェクト: vchateauneu/survol
def Main():
    cgiEnv = lib_common.CgiEnv()
    pidint = int(cgiEnv.GetId())

    grph = cgiEnv.GetGraph()

    node_process = lib_common.gUriGen.PidUri(pidint)

    try:
        # http://daringfireball.net/2010/07/improved_regex_for_matching_urls
        # rgxHttp = "http://[a-zA-Z_0-9\.]*"
        rgxHttp = "http://[a-z_0-9\.]*"

        resuUrls = memory_regex_search.GetRegexMatches(pidint, rgxHttp)

        resuClean = set()

        # The URLs which are detected in the process memory might be broken, invalid etc...
        # Only some of them are in valid strings. The other may come from deallocated memory etc...
        for urlIdx in resuUrls:
            urlHttp = resuUrls[urlIdx]
            # In memory, we find strings such as "http://adblockplus.orgzzzzzzzzzzzz"
            # or "http://adblockplus.orgzzzzzzzzzzzz"
            # "activistpost.netzx"
            urlHttp = str(urlHttp)  # On Python3, this is a bytes array.
            splitDots = urlHttp.split(".")
            topLevel = splitDots[-1]
            # Primitive way to remove apparently broken URLs.
            if (len(topLevel) > 4):
                continue
            resuClean.add(urlHttp)

        for urlHttp in resuClean:
            # sys.stderr.write("urlHttp=%s\n"%urlHttp)
            nodePortalWbem = lib_common.NodeUrl(urlHttp)
            grph.add(
                (node_process, pc.property_rdf_data_nolist1, nodePortalWbem))

    except Exception:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Error:%s. Protection ?" % str(exc))

    cgiEnv.OutCgiRdf()
コード例 #3
0
def Main():
    cgiEnv = lib_common.CgiEnv()
    machineName = cgiEnv.GetId()

    grph = cgiEnv.GetGraph()

    # hostname = "Titi" for example
    # lib_win32.WNetAddConnect(machineName)

    try:
        Win32_Service.FullServiceNetwork(grph, machineName)
    except Exception:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("win32 " + machineName + " services:" +
                                    str(exc))

    # cgiEnv.OutCgiRdf("LAYOUT_RECT")
    # cgiEnv.OutCgiRdf()
    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
コード例 #4
0
def Main():
	cgiEnv = lib_common.CgiEnv()

	grph = cgiEnv.GetGraph()

	pathName = cgiEnv.GetId()

	iconGroups = survol_win32_resource.GetIconNamesList(pathName)

	filNode = lib_common.gUriGen.FileUri(pathName)

	#propNam = ( "/MIME_PROPERTY/" + survol_win32_resource.mimeTypeResource ).replace(" ","_")
	#propIcon = lib_properties.MakeProp(survol_win32_resource.mimeTypeResource)

	for groupName in iconGroups:
		# TODO: Is it sorted in lib_export_html.py ??
		lib_mime.AddMimeUrl(grph,filNode, "win32/resource",survol_win32_resource.mimeTypeResource,[pathName,groupName])

	cgiEnv.OutCgiRdf("LAYOUT_RECT",[pc.property_rdf_data_nolist2] )
コード例 #5
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    rootNode = lib_util.RootUri()

    # This assumes that we have no namespace.
    for entity_type in lib_util.ObjectTypes():

        tmpNode = rootNode
        idx = 0

        while idx >= 0:
            nextSlash = entity_type.find("/", idx + 1)
            if nextSlash == -1:
                intermedType = entity_type
            else:
                intermedType = entity_type[:nextSlash]

            entityNode = lib_util.EntityClassNode(intermedType)
            grph.add((tmpNode, pc.property_directory, entityNode))

            try:
                # This reloads all classes without cache because if it does not load
                # we want to see the error message.
                entity_module = lib_util.GetEntityModuleNoCatch(entity_type)
                entDoc = entity_module.__doc__
            except:
                exc = sys.exc_info()[1]
                entDoc = "Error:" + str(exc)

            if entDoc:
                entDoc = entDoc.strip()
                grph.add((entityNode, pc.property_information,
                          lib_common.NodeLiteral(entDoc)))

            # TODO: If this is a CIM class, add WMI or WBEM documentation, or add the link.

            tmpNode = entityNode
            idx = nextSlash

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
コード例 #6
0
def Main():
    cgiEnv = lib_common.CgiEnv()
    pid_proc = int(cgiEnv.GetId())

    grph = cgiEnv.GetGraph()

    node_process = lib_common.gUriGen.PidUri(pid_proc)
    proc_obj = CIM_Process.PsutilGetProcObj(int(pid_proc))

    # Now we are parsing the command line.
    argv_array = CIM_Process.PsutilProcToCmdlineArray(proc_obj)

    DEBUG("argv_array=%s", str(argv_array))

    # The difficulty is that filenames with spaces are split.
    # Therefore, entire filenames must be rebuilt from pieces.
    _add_nodes_from_command_line(argv_array, grph, node_process, proc_obj)

    cgiEnv.OutCgiRdf()
コード例 #7
0
ファイル: cgi_arp_linux.py プロジェクト: vchateauneu/survol
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    arp_cmd = ["/sbin/arp", "-a"]

    arp_pipe = lib_common.SubProcPOpen(arp_cmd)

    (arp_last_output, arp_err) = arp_pipe.communicate()

    # Converts to string for Python3.
    asstr = arp_last_output.decode("utf-8")

    lines = asstr.split('\n')

    lookup_threads = []

    cnt = 0

    for lin in lines:
        sys.stderr.write("Lin=%s\n" % lin)
        #print("se="+str(seenHyphens)+" Lin=("+lin+")")

        # Maybe should check if other interfaces ??
        # Maybe should create the entity "network interface",
        # instead of this confusion between machines and addresses.

        # BThomehub.home (192.168.1.254) at 18:62:2C:63:98:6A [ether] on eth0
        mtch_arp = re.match("([^ ]+) \(([^)]+)\) at ([^ ]+) .*", lin)

        if not mtch_arp:
            continue

        hostName = mtch_arp.group(1)
        hostNode = lib_common.gUriGen.HostnameUri(hostName)
        grph.add((hostNode, pc.property_information,
                  lib_common.NodeLiteral(mtch_arp.group(2))))
        grph.add((hostNode, pc.property_information,
                  lib_common.NodeLiteral(mtch_arp.group(3))))

    cgiEnv.OutCgiRdf()
コード例 #8
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    try:
        num = 0
        while True:
            try:
                # DO NOT close handle.
                # (<class 'pywintypes.error'>, error(6, 'RegQueryInfoKey', 'The handle is invalid.')
                keyName = win32api.RegEnumKey(
                    lib_com_type_lib.TypeLibRegistryKey, num)
            except win32api.error:
                exc = sys.exc_info()
                WARNING("RegEnumKey CAUGHT:%s", str(exc))
                break

            versions = lib_com_type_lib.ComKeyAllNameVersion(
                lib_com_type_lib.TypeLibRegistryKey, keyName)

            # sys.stderr.write("key=%s\n" % keyName)

            # Name of the last version.
            (bestTypLibName,
             bestVersion) = lib_com_type_lib.ComKeyLastName(versions)
            # sys.stderr.write("BestName=%s\n" % bestTypLibName )

            # for vers, name in list( versions.items() ):
            #	sys.stderr.write("    vers=%s name=%s\n" % (vers,name) )

            # The name will be awful. First we must experiment a bit.
            typelibNode = lib_com_type_lib.CreateComRegisteredTypeLibNode(
                grph, keyName, bestTypLibName, bestVersion)

            num = num + 1
    finally:
        # This avoids:  error(6, 'RegQueryInfoKey', 'The handle is invalid.')
        ERROR("DO NOT close handle")
        # win32api.RegCloseKey(lib_com_type_lib.TypeLibRegistryKey

    cgiEnv.OutCgiRdf()
コード例 #9
0
ファイル: etc_passwd.py プロジェクト: vchateauneu/survol
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    usersList = survol_user.LoadEtcPasswd()

    # User name
    # Information used to validate a user's password; in most modern uses.
    # user identifier number.
    # group identifier number.
    # Gecos field, commentary that describes the person or account.
    # Path to the user's home directory.
    # Program that is started every time the user logs into the system.
    #
    # polkituser:x:17:17:system user for policykit:/:/sbin/nologin
    # puppet:x:103:106:Puppet configuration management daemon,,,:/var/lib/puppet:/bin/false
    for userNam, splitLin in list(usersList.items()):
        userNode = lib_common.gUriGen.UserUri(userNam)
        comment = splitLin[4]
        # Sometimes the comment equals the user, so nothing to mention.
        if comment != "" and comment != userNam:
            grph.add((userNode, pc.property_information,
                      lib_common.NodeLiteral(comment)))
        homePath = splitLin[5]
        if homePath:
            if homePath == "/nonexistent":
                grph.add((userNode, pc.property_information,
                          lib_common.NodeLiteral(homePath)))
            else:
                homeNode = lib_common.gUriGen.DirectoryUri(homePath)
                grph.add((userNode, pc.property_information, homeNode))
        execName = splitLin[6].strip()
        if execName:
            if execName == "/bin/false":
                grph.add((userNode, pc.property_information,
                          lib_common.NodeLiteral(execName)))
            else:
                execNode = lib_common.gUriGen.FileUri(execName)
                grph.add((userNode, pc.property_information, execNode))

    cgiEnv.OutCgiRdf()
コード例 #10
0
ファイル: namespaces_wbem.py プロジェクト: vchateauneu/survol
def Main():
    cgiEnv = lib_common.CgiEnv(can_process_remote=True)

    cimomUrl = cgiEnv.GetHost()

    grph = cgiEnv.GetGraph()

    # There is no consensus on the WBEM class for namespaces,
    # so we have ours which must be correctly mapped.
    namespace_class = "wbem_namespace"
    rootNode = lib_util.EntityUri(namespace_class, "")

    connWbem = lib_wbem.WbemConnection(cimomUrl)

    try:
        nsd = lib_wbem.EnumNamespacesCapabilities(connWbem)
    except Exception:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Namespaces from :" + cimomUrl +
                                    " Caught:" + str(exc))

    # TODO: We should draw a namespaces tree but more examples needed.
    for nskey in nsd:

        cnt = nsd[nskey]
        # Special case because it is not displayed like a normal entity.
        # Oui mais ca marche aussi avec wmi ?
        # Pourrait-on combiner namespace+classe ? entity_type="root/cim_v2/CIM_Process" ?
        # Si l'entity_type termine par un slash, donc c'est un namespace ?
        # Ca nous permettrait de creer des namespaces dans notre ontologie,
        # par exemple pour Oracle. Ce serait simplement un directory.
        # ATTENTION: Avoir la liste de nos entity_types sera moins immediat.
        wbemUrl = lib_wbem.NamespaceUrl(nskey, cimomUrl)
        wbemNode = lib_common.NodeUrl(wbemUrl)

        grph.add((rootNode, pc.property_cim_subnamespace, wbemNode))
        grph.add(
            (wbemNode, pc.property_information, lib_common.NodeLiteral(nskey)))
        grph.add(
            (wbemNode, pc.property_information, lib_common.NodeLiteral(cnt)))

    cgiEnv.OutCgiRdf("LAYOUT_RECT")
コード例 #11
0
ファイル: pefile_depends.py プロジェクト: vchateauneu/survol
def Main():
    cgiEnv = lib_common.CgiEnv()

    win_module = cgiEnv.GetId()

    sys.stderr.write("win_module=%s\n" % win_module)

    lib_win32.CheckWindowsModule(win_module)

    grph = cgiEnv.GetGraph()

    env = EnvPeFile(grph)

    rootNode = env.RecursiveDepends(win_module, maxLevel=8)

    #sys.stderr.write("NbFils=%d\n" % len(env.cache_dll_to_imports))
    #for key in env.cache_dll_to_imports:
    #	sys.stderr.write("Key=%s\n"%key)

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
コード例 #12
0
def Main():
    cgiEnv = lib_common.CgiEnv()
    grph = cgiEnv.GetGraph()

    filCG = open("/proc/cgroups")
    propCGroup = lib_common.MakeProp("cgroup")

    linHeader = filCG.readline()
    for linCG in filCG.readlines():
        splitCG = linCG.split("\t")
        cgroupName = splitCG[0]
        cgroupNode = survol_cgroup.MakeUri(cgroupName)
        grph.add( ( cgroupNode, lib_common.MakeProp("Hierarchy"), lib_common.NodeLiteral(splitCG[1] ) ) )
        grph.add( ( cgroupNode, lib_common.MakeProp("Num cgroups"), lib_common.NodeLiteral(splitCG[2] ) ) )
        grph.add( ( cgroupNode, lib_common.MakeProp("Enabled"), lib_common.NodeLiteral(splitCG[3] ) ) )

        grph.add( ( lib_common.nodeMachine, propCGroup, cgroupNode ) )

        
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [propCGroup] )
コード例 #13
0
def Main():
    cgiEnv = lib_common.CgiEnv()
    try:
        root_pid = int(cgiEnv.GetId())
    except KeyError:
        lib_common.ErrorMessageHtml("Process id should be provided")

    grph = cgiEnv.GetGraph()

    proc_obj = CIM_Process.PsutilGetProcObj(root_pid)

    # Sub-processes, recursion.
    tree_subprocesses(grph, proc_obj)

    # Now display the parent processes.
    # It could be done in a loop instead of recursive calls.
    tree_parent_process(grph, proc_obj, set())

    # This layout style, because the nodes are quite big.
    cgiEnv.OutCgiRdf("LAYOUT_RECT")
コード例 #14
0
def Main():

    # This can process remote hosts because it does not call any script, just shows them.
    cgiEnv = lib_common.CgiEnv()
    entity_id = cgiEnv.m_entity_id
    # entity_host = cgiEnv.GetHost()

    (nameSpace, entity_type, entity_namespace_type) = cgiEnv.GetNamespaceType()

    grph = cgiEnv.GetGraph()

    # rootNode = lib_util.RootUri()

    entity_ids_arr = lib_util.EntityIdToArray(entity_type, entity_id)

    arrTriples = lib_event.data_retrieve(entity_type, entity_ids_arr)
    for tripl in arrTriples:
        grph.add(tripl)

    cgiEnv.OutCgiRdf()
コード例 #15
0
def Main():
    paramkeyPassword = "******"

    cgiEnv = lib_common.CgiEnv({paramkeyPassword: ""})

    if lib_util.isPlatformWindows:
        lib_common.ErrorMessageHtml("smbclient not available on Windows")

    smbShr = cgiEnv.GetId()
    password = cgiEnv.get_parameters(paramkeyPassword)

    nodeSmbShr = lib_common.gUriGen.SmbShareUri(smbShr)

    grph = cgiEnv.GetGraph()

    smbDir = ""

    lib_smbclient.AddFromSmbClient(grph, smbDir, smbShr, password, nodeSmbShr)

    cgiEnv.OutCgiRdf()
コード例 #16
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    pyFilNam = cgiEnv.GetId()

    # sys.stderr.write("dbFilNam=%s\n"%dbFilNam)

    grph = cgiEnv.GetGraph()

    # filNode = lib_common.gUriGen.FileUri(pyFilNam)
    #
    # try:
    #
    # 	AddAssociatedFiles(grph,filNode,pyFilNam)
    # except:
    # 	exc = sys.exc_info()[0]
    # 	lib_common.ErrorMessageHtml("File:%s Unexpected error:%s" % ( pyFilNam, str( exc ) ) )
    # AddImportedModules(grph,filNode,pyFilNam,maxDepth,dispPackages,dispFiles)

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
コード例 #17
0
def Main():

    # This can process remote hosts because it does not call any script, just shows them.
    cgiEnv = lib_common.CgiEnv()
    entity_id = cgiEnv.m_entity_id

    name_space, entity_type = cgiEnv.get_namespace_type()

    grph = cgiEnv.GetGraph()

    # This receives an object type stored as a string, and a string made of the concatenation
    # of key-value pairs, defining an object. It returns the array of property values,
    # in the proper order of the ontology of the type.
    entity_ids_arr = lib_util.EntityIdToArray(entity_type, entity_id)

    arr_triples = lib_event.data_retrieve(entity_type, entity_ids_arr)
    for tripl in arr_triples:
        grph.add(tripl)

    cgiEnv.OutCgiRdf()
コード例 #18
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    propWin32Version = lib_common.MakeProp("Version")
    propWin32Product = lib_common.MakeProp("Win32_Product")
    propWin32Package = lib_common.MakeProp("Package Name")
    propIdentifyingNumber = lib_common.MakeProp("IdentifyingNumber")

    for puid in get_installed_products_uids():
        #sys.stderr.write("puid=%s\n"%puid)
        winProd = Win32_Product.populate_product(puid)
        # Must be encode("utf-8") before printing.
        # "winProd.InstalledProductName=Visual Studio 2012 CARACTERES BIZARRES SDK - cht"
        #try:
        #	sys.stderr.write("winProd.InstalledProductName=%s\n"%winProd.InstalledProductName)
        #except:
        #	sys.stderr.write("winProd.InstalledProductName=%s\n"%winProd.InstalledProductName.encode("utf-8"))

        # BEWARE: WE STRIP THE "{}" AROUND THE PUID
        ############  NOT ANYMORE puid = puid[1:-1]
        productNode = Win32_Product.MakeUri(puid)

        try:
            grph.add((productNode, pc.property_information,
                      lib_common.NodeLiteral(winProd.InstalledProductName)))
            grph.add((productNode, propWin32Version,
                      lib_common.NodeLiteral(winProd.VersionString)))
            grph.add((productNode, propWin32Package,
                      lib_common.NodeLiteral(winProd.PackageName)))
            grph.add((productNode, propIdentifyingNumber,
                      lib_common.NodeLiteral(puid)))

            grph.add((lib_common.nodeMachine, propWin32Product, productNode))

        except:
            exc = sys.exc_info()[1]
            lib_common.ErrorMessageHtml("Caught:%s" % str(exc))

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [propWin32Product])
コード例 #19
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    rootNode = lib_common.nodeMachine

    topWindowsHnd = []
    win32gui.EnumWindows(windowEnumerationHandler, topWindowsHnd)

    prpProcToWindow = lib_common.MakeProp("Top-level window")

    def PidToNode(pid):
        try:
            nodPid = PidToNode.Cache[pid]
        except KeyError:
            nodPid = lib_common.gUriGen.PidUri(pid)
            PidToNode.Cache[pid] = nodPid

            grph.add((nodPid, pc.property_pid, lib_common.NodeLiteral(pid)))
            grph.add((rootNode, pc.property_host, nodPid))

        return nodPid

    PidToNode.Cache = dict()

    sys.stdout.write("Len=%d\n" % len(topWindowsHnd))

    for hwnd in topWindowsHnd:
        wnText = win32gui.GetWindowText(hwnd)
        thrId, procId = win32process.GetWindowThreadProcessId(hwnd)
        nodProcess = PidToNode(procId)
        sys.stderr.write("procId=%d wnText=%s\n" % (procId, wnText))
        if wnText:
            # wnText = wnText.encode("ascii" ,errors='replace')
            # It drops the accent: "Livres, BD, Vidos"
            wnText = wnText.decode("utf8", 'ignore')
            grph.add(
                (nodProcess, prpProcToWindow, lib_common.NodeLiteral(wnText)))

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [prpProcToWindow])
コード例 #20
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    sqlQuery = sql_query.GetEnvArgs(cgiEnv)
    filNam = cgiEnv.m_entity_id_dict["File"]

    nodeSqlQuery = sqlite_query.MakeUri(sqlQuery, filNam)

    propSheetToQuery = lib_common.MakeProp("Table dependency")

    list_of_table_names = lib_sql.TableDependencies(sqlQuery)

    list_of_nodes = sqlite_query.QueryToNodesList(sqlQuery, {"File": filNam},
                                                  list_of_table_names)

    for nodTab in list_of_nodes:
        grph.add((nodeSqlQuery, propSheetToQuery, nodTab))

    cgiEnv.OutCgiRdf()
コード例 #21
0
def Main():

    paramkeyMaximumDepth = "Maximum depth"

    cgiEnv = lib_common.CgiEnv(parameters={paramkeyMaximumDepth: 3})

    maxDepth = int(cgiEnv.get_parameters(paramkeyMaximumDepth))

    win_module = cgiEnv.GetId()

    DEBUG("win_module=%s", win_module)

    lib_win32.CheckWindowsModule(win_module)

    grph = cgiEnv.GetGraph()

    env = EnvPeFile(grph)

    rootNode = env.RecursiveDepends(win_module, maxDepth)

    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_symbol_declared])
コード例 #22
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    dsnNam = survol_odbc_dsn.GetDsnNameFromCgi(cgiEnv)

    sys.stderr.write("dsn=(%s)\n" % dsnNam )

    nodeDsn = survol_odbc_dsn.MakeUri( dsnNam )

    ODBC_ConnectString = survol_odbc_dsn.MakeOdbcConnectionString(dsnNam)

    try:
        cnxn = pyodbc.connect(ODBC_ConnectString)
        sys.stderr.write("Connected: %s\n" % dsnNam)
        cursor = cnxn.cursor()

        # http://pyodbc.googlecode.com/git/web/docs.html
        colList = ( "Catalog", "Schema", "Procedure", "Inputs", "Outputs", "Result", "Remarks", "Type")

        # This avoids cursor.fetchall()
        for row in cursor.procedures():
            # TODO: What are the other properties ??
            procNam = row[2]
            # sys.stderr.write("tabNam=%s\n" % tabNam)

            nodProc = survol_odbc_procedure.MakeUri( dsnNam, procNam )
            grph.add( (nodeDsn, pc.property_odbc_procedure, nodProc ) )

            for idxCol in (3, 4, 5, 6, 7):
                grph.add( (nodProc, lib_common.NodeLiteral(colList[idxCol]), lib_common.NodeLiteral(row[idxCol]) ) )

    except Exception:
        exc = sys.exc_info()[0]
        lib_common.ErrorMessageHtml("nodeDsn=%s Unexpected error:%s" % ( dsnNam, str( sys.exc_info() ) ) )


    # cgiEnv.OutCgiRdf()
    cgiEnv.OutCgiRdf("LAYOUT_RECT", [pc.property_odbc_procedure] )
コード例 #23
0
def Main():

	cgiEnv = lib_common.CgiEnv()

	configNam = cgiEnv.GetId()

	nodeManager = survol_rabbitmq_manager.MakeUri(configNam)

	creds = lib_credentials.GetCredentials( "RabbitMQ", configNam )

	# cl = Client('localhost:12345', 'guest', 'guest')
	cl = Client(configNam, creds[0], creds[1])

	grph = cgiEnv.GetGraph()

	# >>> cl.get_connections()[0]
	# http://localhost:12345/api/connections
	# {u'frame_max': 131072, u'send_pend': 0, u'protocol': u'AMQP 0-9-1', u'client_properties': {u'information': u'Licensed under the MPL.
	#   See http://www.rabbitmq.com/', u'product': u'RabbitMQ', u'copyright': u'Copyright (C) 2007-2014 GoPivotal, Inc.', u'capabilities':
	#  {u'exchange_exchange_bindings': True, u'connection.blocked': True, u'authentication_failure_close': True, u'basic.nack': True, u'co
	# nsumer_cancel_notify': True, u'publisher_confirms': True}, u'platform': u'.NET', u'version': u'4.5.2.30002'}, u'reductions': 9840145
	# , u'ssl_protocol': None, u'garbage_collection': {u'min_heap_size': 233, u'fullsweep_after': 65535, u'minor_gcs': 1, u'min_bin_vheap_
	# size': 46422}, u'peer_cert_validity': None, u'channels': 42, u'auth_mechanism': u'PLAIN', u'peer_cert_issuer': None, u'peer_cert_sub
	# ject': None, u'port': 5672, u'recv_oct_details': {u'rate': 29.4}, u'channel_max': 0, u'send_oct_details': {u'rate': 1140.8}, u'recv_
	# cnt': 69333, u'send_oct': 56500718, u'peer_host': u'127.0.0.1', u'state': u'running', u'ssl_cipher': None, u'type': u'network', u'no
	# de': u'rabbit@rchateau-HP', u'send_cnt': 69409, u'peer_port': 51532, u'ssl_hash': None, u'host': u'127.0.0.1', u'connected_at': 1486
	# 974214456L, u'user': u'guest', u'name': u'127.0.0.1:51532 -> 127.0.0.1:5672', u'ssl': False, u'vhost': u'/', u'recv_oct': 1461716, u
	# 'timeout': 60, u'ssl_key_exchange': None, u'reductions_details': {u'rate': 197.4}}


	try:
		listConnections = cl.get_connections()
	except:
		exc = sys.exc_info()[1]
		lib_common.ErrorMessageHtml("Caught:"+str(exc))

	if listConnections:
		AddConnections(grph,listConnections,configNam,nodeManager)

	cgiEnv.OutCgiRdf()
コード例 #24
0
def Main():

    # This can process remote hosts because it does not call any script, just shows them.
    cgiEnv = lib_common.CgiEnv(can_process_remote=True,
                               parameters={lib_util.paramkeyShowAll: False})
    entity_id = cgiEnv.m_entity_id
    entity_host = cgiEnv.GetHost()
    flagShowAll = int(cgiEnv.get_parameters(lib_util.paramkeyShowAll))

    nameSpace, entity_type = cgiEnv.get_namespace_type()

    if lib_util.IsLocalAddress(entity_host):
        entity_host = ""

    DEBUG("entity: entity_host=%s entity_type=%s entity_id=%s", entity_host,
          entity_type, entity_id)

    grph = cgiEnv.GetGraph()

    rootNode = lib_util.RootUri()

    if entity_id != "" or entity_type == "":
        entity_ids_arr = lib_util.EntityIdToArray(entity_type, entity_id)

        # TODO: Plutot qu'attacher tous les sous-directory a node parent,
        # ce serait peut-etre mieux d'avoir un seul lien, et d'afficher
        # les enfants dans une table, un record etc...
        # OU: Certaines proprietes arborescentes seraient representees en mettant
        # les objets dans des boites imbriquees: Tables ou records.
        # Ca peut marcher quand la propriete forme PAR CONSTRUCTION
        # un DAG (Direct Acyclic Graph) qui serait alors traite de facon specifique.

        def CallbackGrphAdd(tripl, depthCall):
            grph.add(tripl)

        DirToMenu(CallbackGrphAdd, rootNode, entity_type, entity_id,
                  entity_host, flagShowAll)

    cgiEnv.OutCgiRdf("LAYOUT_RECT",
                     [pc.property_directory, pc.property_script])
コード例 #25
0
def Main():
    cgiEnv = lib_common.CgiEnv()
    pid = int( cgiEnv.GetId() )

    grph = cgiEnv.GetGraph()

    procNode = lib_common.gUriGen.PidUri(pid)

    remSta = GetRemoteStack(pid)

    if remSta:
        callNodePrev = None

        for st in remSta:
            # == fichier=../essai.py line=6 module=<module>
            # == fichier=<string> line=1 module=<module>
            # == fichier=/tmp/tmpw14tgJ.py line=9 module=<module>
            sys.stderr.write("== fichier=%s line=%d module=%s\n" % ( st[0], st[1], st[2] ) )

            shortFilNam = st[0]
            lineNumber = st[1]
            moduleNam = st[2]

            # TODO: What is the full path name ?
            fileName = shortFilNam
            funcName = moduleNam

            # TODO: At each stage, should add the variables defined in each function call.

            # See process_gdbstack.py
            callNodePrev = survol_symbol.AddFunctionCall( grph, callNodePrev, procNode, funcName, fileName, lineNumber )

            if not callNodePrev:
                break
    else:
        sys.stderr.write("No stack visible\n")


    cgiEnv.OutCgiRdf()
コード例 #26
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    entity_type = "dbus/connection"
    # entity_id = cgiEnv.m_entity_id
    # entity_ids_arr = lib_util.EntityIdToArray( entity_type, entity_id )
    # entity_ids_dict = lib_util.SplitMoniker(entity_id)

    # busAddr = entity_ids_arr[0]
    # connectName = entity_ids_arr[1]
    Main.busAddr = cgiEnv.m_entity_id_dict["Bus"]
    Main.connectName = cgiEnv.m_entity_id_dict["Connect"]

    try:
        Main.theBus = lib_dbus.MakeBusFromAddress(Main.busAddr)
    except Exception:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("busAddr=%s Caught:%s" %
                                    (Main.busAddr, str(exc)))

    connectNode = lib_util.EntityUri(entity_type, Main.busAddr,
                                     Main.connectName)

    grph = cgiEnv.GetGraph()

    Main.localPropDbusPath = lib_common.NodeLiteral("dbus-path")

    try:
        RecursiveObjWalk(grph, "/", connectNode)
    except dbus.exceptions.DBusException as exc:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught DBusException busAddr=%s %s" %
                                    (Main.busAddr, str(exc)))
    except dbus.proxies as exc:
        exc = sys.exc_info()[1]
        lib_common.ErrorMessageHtml("Caught proxies busAddr=%s %s" %
                                    (Main.busAddr, str(exc)))

    cgiEnv.OutCgiRdf()
コード例 #27
0
def Main():

    # This can process remote hosts because it does not call any script, just shows them.
    cgiEnv = lib_common.CgiEnv(can_process_remote=True)

    grph = cgiEnv.GetGraph()

    entity_type = cgiEnv.m_entity_type
    entity_host = cgiEnv.GetHost()
    entity_host = lib_wmi.NormalHostName(entity_host)

    # TODO: We may also loop on all machines which may describe this object.
    wmiurl = lib_wmi.GetWmiUrl(entity_host, "", "", "")
    if not wmiurl is None:
        wmiNode = lib_common.NodeUrl(wmiurl)

        hostNode = lib_common.gUriGen.HostnameUri(entity_host)
        grph.add((hostNode, pc.property_information, wmiNode))
    else:
        lib_common.ErrorMessageHtml("WMI module not installed\n")

    cgiEnv.OutCgiRdf()
コード例 #28
0
ファイル: current_script.py プロジェクト: vchateauneu/survol
def Main():
    cgiEnv = lib_common.CgiEnv()
    pidProc = int(cgiEnv.GetId())

    grph = cgiEnv.GetGraph()

    node_process = lib_common.gUriGen.PidUri(pidProc)
    proc_obj = CIM_Process.PsutilGetProcObj(int(pidProc))

    # Now we are parsing the command line.
    cmd_line = CIM_Process.PsutilProcToCmdline(proc_obj)

    sys.stderr.write("cmd_line=%s\n" % str(cmd_line))

    # Similar to split, but ignores white spaces in double quotes.
    argvArray = re.findall(r'(?:[^\s "]|"(?:\\.|[^"])*")+', cmd_line)

    sys.stderr.write("argvArray=%s\n" % str(argvArray))

    argvArgs = " ".join(argvArray[1:])

    sys.stderr.write("argvArgs=%s\n" % argvArgs)

    opts, otherArgs = getopt.getopt(argvArgs, "Bc:dEhim:ORQ:sStuvVW:x3")

    ignoreEnvs = False
    for opt, arg in opts:
        if opt == '-E':
            ignoreEnvs = True

    if otherArgs:
        filNam = otherArgs
        filNode = PyFilNode(proc_obj, filNam, ignoreEnvs)
        if filNode:
            grph.add((node_process, pc.property_runs, filNode))

        sys.stderr.write("filNam=%s\n" % filNam)

    cgiEnv.OutCgiRdf()
コード例 #29
0
def Main():
	cgiEnv = lib_common.CgiEnv()

	grph = cgiEnv.GetGraph()

	# subscriptionName=Azure.DefaultSubscription()
	subscriptionName = cgiEnv.m_entity_id_dict["Subscription"]

	(subscription_id,certificate_path) = lib_credentials.GetCredentials( "Azure", subscriptionName )

	sms = ServiceManagementService(subscription_id, certificate_path)

	subscriptionNode = subscription.MakeUri( subscriptionName )

	# There are a lot of informations
	grph.add( ( subscriptionNode, lib_common.MakeProp(".cert_file"), lib_common.NodeLiteral(sms.cert_file)) )
	grph.add( ( subscriptionNode, lib_common.MakeProp(".requestid"), lib_common.NodeLiteral(sms.requestid)) )
	grph.add( ( subscriptionNode, lib_common.MakeProp(".x_ms_version"), lib_common.NodeLiteral(sms.x_ms_version)) )
	grph.add( ( subscriptionNode, lib_common.MakeProp("Azure"), lib_common.NodeLiteral(str(dir(sms))) ) )

	#propOperatingSystem = lib_common.MakeProp("Operating System")
	#for opsys in sms.list_operating_systems():
	#	sys.stderr.write("opsys=%s\n"%str(dir(opsys)))
	#	grph.add( ( subscriptionNode, propOperatingSystem, lib_common.NodeLiteral(opsys.family_label)) )

	propOperatingSystemFamily = lib_common.MakeProp("Operating System Family")

	try:
		# This throws when running with Apache. OK with cgiserver.py
		lstOSes = sms.list_operating_system_families()
	except:
		lib_common.ErrorMessageHtml("Unexpected error:" + str( sys.exc_info() ) )

	for opsys in lstOSes:
		# sys.stderr.write("opsys=%s\n"%str(dir(opsys)))
		grph.add( ( subscriptionNode, propOperatingSystemFamily, lib_common.NodeLiteral(opsys.label)) )

	cgiEnv.OutCgiRdf("LAYOUT_RECT",[propOperatingSystemFamily])
コード例 #30
0
ファイル: queue_bindings.py プロジェクト: vchateauneu/survol
def Main():

    cgiEnv = lib_common.CgiEnv()

    configNam = cgiEnv.m_entity_id_dict["Url"]
    namVHost = cgiEnv.m_entity_id_dict["VHost"]
    namQueue = cgiEnv.m_entity_id_dict["Queue"]

    nodeManager = survol_rabbitmq_manager.MakeUri(configNam)

    creds = lib_credentials.GetCredentials("RabbitMQ", configNam)

    # cl = Client('localhost:12345', 'guest', 'guest')
    cl = Client(configNam, creds[0], creds[1])

    grph = cgiEnv.GetGraph()

    nodVHost = survol_rabbitmq_vhost.MakeUri(configNam, namVHost)
    grph.add((nodeManager, lib_common.MakeProp("virtual host node"), nodVHost))

    nodeQueue = survol_rabbitmq_queue.MakeUri(configNam, namVHost, namQueue)
    grph.add((nodVHost, lib_common.MakeProp("Queue"), nodeQueue))

    # >>> cl.get_queue_bindings("/","aliveness-test")
    # [{u'vhost': u'/', u'properties_key': u'aliveness-test', u'destination': u'aliveness-test', u'routing_key': u'aliveness-test', u'sour
    # ce': u'', u'arguments': {}, u'destination_type': u'queue'}]
    lstBindings = cl.get_queue_bindings(namVHost, namQueue)

    for sublstBindings in lstBindings:
        for keyBindings in sublstBindings:
            valBindings = sublstBindings[keyBindings]
            strDisp = str(valBindings).replace("{", "").replace("}", "")
            grph.add((nodeQueue, lib_common.MakeProp(keyBindings),
                      lib_common.NodeLiteral(strDisp)))
            sys.stderr.write("keyBindings=%s valBindings=%s\n" %
                             (keyBindings, valBindings))

    cgiEnv.OutCgiRdf()