Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
I
inary
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
1
Konular (issue)
1
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
inary
Commits
4fc16251
Kaydet (Commit)
4fc16251
authored
Kas 14, 2018
tarafından
Suleyman Poyraz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Deleted unuseful functions
Modules deleted in analyzer method dir because of unuseful.
üst
6e3d5072
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
271 deletions
+0
-271
firmwares.py
inary/analyzer/firmwares.py
+0
-66
forensic.py
inary/analyzer/forensic.py
+0
-111
urgent-packages.py
inary/analyzer/urgent-packages.py
+0
-94
No files found.
inary/analyzer/firmwares.py
deleted
100644 → 0
Dosyayı görüntüle @
6e3d5072
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018, Suleyman POYRAZ (Zaryob)
#
# 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 3 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import
os
import
sys
import
inary.context
as
ctx
import
inary.db
import
inary.errors
import
inary.util
#Gettext
import
gettext
__trans
=
gettext
.
translation
(
'inary'
,
fallback
=
True
)
_
=
__trans
.
gettext
class
Error
(
inary
.
errors
.
Error
):
pass
def
get_firmwares
():
ctx
.
ui
.
info
(
_
(
"Extracting firmware list for {}..."
)
.
format
(
os
.
uname
()[
2
]),
color
=
"green"
)
d
=
{}
modules
=
[
os
.
path
.
basename
(
mod
.
replace
(
".ko"
,
""
))
for
mod
in
\
os
.
popen
(
"modprobe -l"
)
.
read
()
.
strip
()
.
split
(
"
\n
"
)]
for
mod
in
modules
:
fws
=
os
.
popen
(
"modinfo -F firmware {}"
.
format
(
mod
))
.
read
()
.
strip
()
if
fws
:
try
:
d
[
mod
]
.
extend
(
fws
.
split
(
"
\n
"
))
except
KeyError
:
d
[
mod
]
=
fws
.
split
(
"
\n
"
)
return
d
def
get_firmware_package
(
firmware
):
try
:
fw_packages
=
inary
.
db
.
componentdb
.
ComponentDB
()
.
get_packages
(
"hardware.firmware"
)
unavailable_fw_packages
=
set
(
fw_packages
)
.
difference
(
inary
.
db
.
installdb
.
InstallDB
()
.
list_installed
())
if
unavailable_fw_packages
:
ctx
.
ui
.
info
(
_
(
"The following firmwares are not installed:"
),
color
=
"yellow"
)
ctx
.
ui
.
info
(
"
\n
"
.
join
(
unavailable_fw_packages
))
for
module
,
firmwares
in
list
(
get_firmwares
()
.
items
()):
ctx
.
ui
.
info
(
"
\n
{} requires the following firmwares:"
.
format
(
module
))
for
fw
in
firmwares
:
ctx
.
ui
.
info
(
" * {}"
.
format
(
fw
),
noln
=
True
)
try
:
if
fw
.
startswith
(
"/"
):
fw
=
fw
[
1
:]
firmware
=
ctx
.
filesdb
.
search_file
(
fw
)[
0
][
0
]
except
:
pass
ctx
.
ui
.
info
(
" ({})"
.
format
(
inary
.
util
.
colorize
(
firmware
,
'green'
)
if
firmware
else
\
inary
.
util
.
colorize
(
_
(
"Missing"
),
'red'
)))
except
:
raise
Error
()
inary/analyzer/forensic.py
deleted
100644 → 0
Dosyayı görüntüle @
6e3d5072
# -*- coding: utf-8 -*-
"""
Forensic finder Sulin harici dağıtımlara paket kurulumunda
sorun yaşamadan işimizi halletmemizi sağlayabilir.
mevcut repodaki paketlerin files listesine bakılarak yüklü paket
listesi çıkartılabilir bence.
"""
import
hashlib
import
os
import
sys
import
time
import
inary.db
import
inary.operations
IGNORE_DIRS
=
(
'/root'
,
'/tmp'
,
'/home'
,
'/media'
,
'/mnt'
,
'/proc'
,
'/sys'
,
'/dev'
,
'/var/run'
,
'/var/inary'
,
'/var/lib/inary'
,
'/var/tmp'
,
'/var/log'
,
'/var/db/sudo'
,
'/var/lock/subsys'
,
'/var/spool'
,
'/var/cache'
,
'/var/db/scom3/scripts'
,
'/var/db/scom3/apps'
,
'/var/lib/mysql/mysql'
,
'/etc/scomd/services'
)
IGNORE_EXTS
=
(
'.pyc'
,
'.pid'
)
def
get_hash
(
filepath
):
def
_hash
(
_str
):
return
hashlib
.
sha1
(
_str
.
encode
(
'utf-8'
))
.
hexdigest
()
if
os
.
path
.
islink
(
filepath
):
data
=
os
.
path
.
realpath
(
filepath
)
else
:
data
=
open
(
filepath
)
.
read
()
return
_hash
(
data
)
def
find_unowned
(
rootdir
,
last_unowned
):
db
=
inary
.
db
.
installdb
.
InstallDB
()
all_files
=
[]
for
package
in
inary
.
db
.
installdb
.
InstallDB
()
.
list_installed
():
files
=
[
'/'
+
x
.
path
for
x
in
db
.
get_files
(
package
)
.
list
]
all_files
.
extend
(
files
)
filepaths
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
rootdir
):
if
root
in
IGNORE_DIRS
:
while
len
(
dirs
):
dirs
.
pop
()
continue
for
name
in
files
:
if
name
.
endswith
(
IGNORE_EXTS
):
continue
filepath
=
os
.
path
.
join
(
root
,
name
)
if
filepath
not
in
all_files
and
filepath
not
in
last_unowned
:
ctx
.
ui
.
info
(
"UNOWNED
%
s
\n
"
%
filepath
)
def
find_corrupted
(
rootdir
,
last_changed
):
for
package
in
inary
.
db
.
installdb
.
InstallDB
()
.
list_installed
():
check
=
inary
.
operations
.
check
.
check_package
(
package
,
config
=
False
)
for
filepath
in
check
[
'corrupted'
]:
filepath
=
'/'
+
filepath
if
not
filepath
.
startswith
(
rootdir
):
continue
if
filepath
not
in
last_changed
or
last_changed
[
filepath
]
!=
get_hash
(
filepath
):
ctx
.
ui
.
info
(
"CHANGED
%
s
%
s
%
s
\n
"
%
(
get_hash
(
filepath
),
package
,
filepath
))
for
filepath
in
check
[
'missing'
]:
filepath
=
'/'
+
filepath
if
not
filepath
.
startswith
(
rootdir
):
continue
ctx
.
ui
.
info
(
"MISSING {0} {1}
\n
"
.
format
(
package
,
filepath
))
def
forensics
(
rootdir
=
'/'
,
logfile
=
'logfile'
):
if
not
rootdir
.
endswith
(
'/'
):
rootdir
+=
'/'
if
logfile
:
pass
else
:
logfile
=
None
last_unowned
=
[]
last_changed
=
{}
if
logfile
:
for
line
in
open
(
logfile
):
line
=
line
.
strip
()
if
line
.
startswith
(
"UNOWNED"
):
_type
,
_filepath
=
line
.
split
(
' '
,
1
)
last_unowned
.
append
(
_filepath
)
elif
line
.
startswith
(
"CHANGED"
):
_type
,
_hash
,
_package
,
_filepath
=
line
.
split
(
' '
,
3
)
last_changed
[
_filepath
]
=
_hash
find_unowned
(
rootdir
,
last_unowned
)
find_corrupted
(
rootdir
,
last_changed
)
inary/analyzer/urgent-packages.py
deleted
100644 → 0
Dosyayı görüntüle @
6e3d5072
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018, Suleyman POYRAZ (Zaryob)
#
# 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 3 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import
ciksemel
import
bz2
import
sys
import
os
def
loadFile
(
_file
):
try
:
f
=
open
(
_file
)
d
=
[
a
.
lstrip
()
.
rstrip
(
"
\n
"
)
for
a
in
f
]
d
=
[
x
for
x
in
d
if
not
(
x
.
startswith
(
"#"
)
or
x
==
""
)]
f
.
close
()
return
d
except
:
return
[]
def
getXmlData
(
_file
):
if
os
.
path
.
exists
(
_file
):
return
minidom
.
parse
(
_file
)
.
documentElement
elif
os
.
path
.
exists
(
"{}.bz2"
.
format
(
_file
)):
indexdata
=
bz2
.
decompress
(
open
(
"{}.bz2"
.
format
(
_file
))
.
read
())
return
minidom
.
parseString
(
indexdata
)
else
:
print
(
"{} not found"
.
format
(
indexfile
))
sys
.
exit
(
1
)
def
fillPackageDict
(
tag
,
_hasSpecFile
,
packageOf
):
PackagePartOf
=
tag
.
getElementsByTagName
(
"PartOf"
)[
0
]
PackageName
=
tag
.
getElementsByTagName
(
"Name"
)[
0
]
if
_hasSpecFile
:
PackagePackagerName
=
tag
.
getElementsByTagName
(
"Packager"
)[
0
]
.
getElementsByTagName
(
"Name"
)[
0
]
.
firstChild
.
data
else
:
PackagePackagerName
=
tag
.
getElementsByTagName
(
"Source"
)[
0
]
.
getElementsByTagName
(
"Packager"
)[
0
]
.
getElementsByTagName
(
"Name"
)[
0
]
.
firstChild
.
data
fullpath
=
"{0}/{1}"
.
format
(
PackagePartOf
.
replace
(
"."
,
"/"
),
PackageName
)
if
not
PackagePackagerName
in
packageOf
:
packageOf
[
PackagePackagerName
]
=
[]
packageOf
[
PackagePackagerName
]
.
append
(
fullpath
)
def
parseXmlData
(
_index
):
packageOf
=
{}
hasSpecFile
=
_index
.
getTag
(
"SpecFile"
)
if
hasSpecFile
:
for
i
in
_index
.
tags
(
"SpecFile"
):
parent
=
i
.
getTag
(
"Source"
)
fillPackageDict
(
parent
,
hasSpecFile
,
packageOf
)
else
:
for
parent
in
_index
.
tags
(
"Package"
):
fillPackageDict
(
parent
,
hasSpecFile
,
packageOf
)
return
packageOf
def
findRequiredPackages
(
packageList
,
packagersList
):
pkgdict
=
{}
for
pkg
in
packageList
:
for
packager
in
packagersList
:
for
sourcePackage
in
packagersList
[
packager
]:
if
sourcePackage
.
endswith
(
"/{}"
.
format
(
pkg
)):
if
not
packager
in
pkgdict
:
pkgdict
[
packager
]
=
[]
pkgdict
[
packager
]
.
append
(
pkg
)
return
pkgdict
def
urgent_packages
(
index
,
packages
):
indexfile
=
"{0}/{1}"
.
format
(
index
,
"inary-index.xml"
)
packageList
=
loadFile
(
packages
)
xmldata
=
getXmlData
(
indexfile
)
packagers
=
parseXmlData
(
xmldata
)
requiredPackages
=
findRequiredPackages
(
packageList
,
packagers
)
tmp
=
list
(
requiredPackages
.
keys
())
tmp
.
sort
()
# for i in tmp:
# print("-> %s" % i)
# for k in requiredPackages[i]:
# print("\t%s" % k)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment