chroblert / AssetManage

278 stars 97 forks source link

后端提示错误,Internal Server Error: /baseline/linux_scan_res_report/ #6

Closed yq513 closed 4 years ago

yq513 commented 4 years ago

linux执行脚本,web页面收不到检查信息,后端服务器提示如下,请教原因,感谢 Internal Server Error: /baseline/linux_scan_res_report/ Traceback (most recent call last): File "/opt/py3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/opt/py3/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/opt/py3/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, *callback_kwargs) File "/opt/py3/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(args, **kwargs) File "/opt/pyhton3/AssetManage/baseline/views.py", line 519, in linux_scan_res_report ck_userHomeDirPermissionArray="True" if "False" not in userHomeDirPermissionArray and "False" not in [int(i) > 750 for i in userHomeDirPermissionArray.split(";")[:-1]] else "False" File "/opt/pyhton3/AssetManage/baseline/views.py", line 519, in ck_userHomeDirPermissionArray="True" if "False" not in userHomeDirPermissionArray and "False" not in [int(i) > 750 for i in userHomeDirPermissionArray.split(";")[:-1]] else "False" ValueError: invalid literal for int() with base 10: 'drwx------' [14/Feb/2020 14:03:11] "POST /baseline/linux_scan_res_report/ HTTP/1.1" 500 135368

image

chroblert commented 4 years ago

ck_userHomeDirPermissionArray="True" if "False" not in userHomeDirPermissionArray and "False" not in [int(i) > 750 for i in userHomeDirPermissionArray.split(";")[:-1]] else "False"

你好,我有看到你的问题 但之前没时间回复 这次可能是bug,判断不严谨的问题

看上面的提示应该是userHomeDirPermissionArray这个变量的值出现了问题

yq513 commented 4 years ago

你好, 这个有空回复就很感谢, 请教 这个变量改哪些地方能改好, 或者等你更新在下载。

chroblert commented 4 years ago

你好, 这个有空回复就很感谢, 请教 这个变量改哪些地方能改好, 或者等你更新在下载。

image

image 刚看了下问题,linux_baseline_check.sh文件的第1006行获取到的是一个drwx,而后端服务器使用int()强转,因而出现了问题 解决方式:将1006行的local dirperm=$(ls -ld $dir|cut -d" " -f1)替换成local dirperm=$(stat -c %a $dir)

yq513 commented 4 years ago

你好 改了后 提示如下 image

yq513 commented 4 years ago

我这边图片看不到,弄个文字的。 改后 后端最后几行提示如下: File "/opt/py3/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(args, kwargs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 538, in get_or_create return self.get(kwargs), False File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 399, in get clone = self.filter(args, kwargs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 892, in filter return self._filter_or_exclude(False, *args, *kwargs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 910, in _filter_or_exclude clone.query.add_q(Q(args, kwargs)) File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1290, in addq clause, = self._add_q(q_object, self.used_aliases) File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1318, in _add_q split_subq=split_subq, simple_col=simple_col, File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1251, in build_filter condition = self.build_lookup(lookups, col, value) File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1116, in build_lookup lookup = lookup_class(lhs, rhs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/lookups.py", line 20, in init self.rhs = self.get_prep_lookup() File "/opt/py3/lib/python3.6/site-packages/django/db/models/lookups.py", line 70, in get_prep_lookup return self.lhs.output_field.get_prep_value(self.rhs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/fields/init.py", line 1018, in get_prep_value return self.to_python(value) File "/opt/py3/lib/python3.6/site-packages/django/db/models/fields/init.py", line 1011, in to_python params={'value': value}, django.core.exceptions.ValidationError: ['’‘ 必须为 True 或者 False。']

chroblert commented 4 years ago

应该是一个本应是布尔值的类型却不是布尔值,而是’‘ ,提示里看不出哪里出现了问题。需要到LinuxScanResMeta数据库中查看值为’‘ 或空的字段,找到后麻烦提示一下哈

yq513 commented 4 years ago

临时学了下 这个数据库的一些知识, 这个数据库好像没有表?不知道我看的对不对。 image [root@zhx-app db]# sqlite3 LinuxScanResMet.db SQLite version 3.27.2 2019-02-25 16:06:06 Enter ".help" for usage hints. sqlite> .databases main: /usr/share/ibus-libpinyin/db/LinuxScanResMet.db sqlite> select name from sqlite_master where type='table' order by name; sqlite> .dbinfo unable to read database header sqlite> .show echo: off eqp: off explain: auto headers: off mode: list nullvalue: "" output: stdout colseparator: "|" rowseparator: "\n" stats: off width: filename: LinuxScanResMet.db sqlite> select * from sqlite_master; sqlite> select name from sqlite_master where type='table' order by name; sqlite>

另贴上 linux执行脚本后 ,后端的全部提示 全部提示如下: Internal Server Error: /baseline/linux_scan_res_report/ Traceback (most recent call last): File "/opt/py3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/opt/py3/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/opt/py3/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/opt/py3/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, *kwargs) File "/opt/pyhton3/AssetManage/baseline/views.py", line 536, in linux_scan_res_report models.LinuxScanRes.objects.get_or_create(scanTime=scanTime,hostname=hostname,macaddr=macaddr,ipList=ipList,kernelVersion=kernelVersion,osVersion=osVersion,tmpIfSeparate=tmpIfSeparate,tmpIfNoexec=tmpIfNoexec,tmpIfNosuid=tmpIfNosuid,grubcfgIfExist=grubcfgIfExist,grubcfgPermission=grubcfgPermission,grubcfgIfSetPasswd=grubcfgIfSetPasswd,singleUserModeIfNeedAuth=singleUserModeIfNeedAuth,selinuxStateIfEnforcing=selinuxStateIfEnforcing,selinuxPolicyIfConfigured=selinuxPolicyIfConfigured,timeSyncServerIfConfigured=timeSyncServerIfConfigured,x11windowIfNotInstalled=x11windowIfNotInstalled,hostsAllowFileIfExist=hostsAllowFileIfExist,hostsAllowFilePermission=hostsAllowFilePermission,hostsAllowFileIfConfigured=hostsAllowFileIfConfigured,hostsDenyFileIfExist=hostsDenyFileIfExist,hostsDenyFilePermission=hostsDenyFilePermission,hostsDenyFileIfConfigured=hostsDenyFileIfConfigured,iptablesIfInstalled=iptablesIfInstalled,iptablesInputPolicyIfDrop=iptablesInputPolicyIfDrop,iptablesOutputPolicyIfDrop=iptablesOutputPolicyIfDrop,auditdIfEnabled=auditdIfEnabled,auditdconfIfExist=auditdconfIfExist,auditdIfSetMaxLogFile=auditdIfSetMaxLogFile,auditdIfSetMaxLogFileAction=auditdIfSetMaxLogFileAction,auditdIfSetSpaceLeftAction=auditdIfSetSpaceLeftAction,auditdIfSetNumLogs=auditdIfSetNumLogs,auditdRulesIfExist=auditdRulesIfExist,auditdRulesIfNotNull=auditdRulesIfNotNull,auditdIfCheckTimechange=auditdIfCheckTimechange,auditdRulesCheckedUserandgroupfile=auditdRulesCheckedUserandgroupfile,auditdRulesNotCheckedUserandgroupfile=auditdRulesNotCheckedUserandgroupfile,auditdRulesCheckedNetworkenv=auditdRulesCheckedNetworkenv,auditdRulesNotCheckedNetworkenv=auditdRulesNotCheckedNetworkenv,auditdRulesCheckedMACchange=auditdRulesCheckedMACchange,auditdRulesNotCheckedMACchange=auditdRulesNotCheckedMACchange,auditdRulesCheckedLoginoutEvents=auditdRulesCheckedLoginoutEvents,auditdRulesNotCheckedLoginoutEvents=auditdRulesNotCheckedLoginoutEvents,auditdRulesCheckedDACChangeSyscall=auditdRulesCheckedDACChangeSyscall,auditdRulesNotCheckedDACChangeSyscall=auditdRulesNotCheckedDACChangeSyscall,auditdRulesCheckedFileAccessAttemptSyscall=auditdRulesCheckedFileAccessAttemptSyscall,auditdRulesNotCheckedFileAccessAttemptSyscall=auditdRulesNotCheckedFileAccessAttemptSyscall,auditdRulesCheckedPrivilegedCommand=auditdRulesCheckedPrivilegedCommand,auditdRulesNotCheckedPrivilegedCommand=auditdRulesNotCheckedPrivilegedCommand,auditdRulesCheckedSudoerFile=auditdRulesCheckedSudoerFile,auditdRulesNotCheckedSudoerFile=auditdRulesNotCheckedSudoerFile,auditdRulesIfImmutable=auditdRulesIfImmutable,rsyslogIfEnabled=rsyslogIfEnabled,crondIfEnabled=crondIfEnabled,crondConfigFilenameArray=crondConfigFilenameArray,crondConfigFilePermissionArray=crondConfigFilePermissionArray,crondallowdenyFilenameArray=crondallowdenyFilenameArray,crondallowdenyFileIfExistArray=crondallowdenyFileIfExistArray,crondallowdenyFilePermissionArray=crondallowdenyFilePermissionArray,crondallowdenyFileOwnerArray=crondallowdenyFileOwnerArray,sshdIfEnabled=sshdIfEnabled,sshdConfigFilePermission=sshdConfigFilePermission,sshdIfDisableX11forwarding=sshdIfDisableX11forwarding,sshdIfSetMaxAuthTries=sshdIfSetMaxAuthTries,sshdIfEnableIgnoreRhosts=sshdIfEnableIgnoreRhosts,sshdIfDisableHostbasedAuthentication=sshdIfDisableHostbasedAuthentication,sshdIfDisablePermitRootLogin=sshdIfDisablePermitRootLogin,sshdIfDisablePermitEmptyPasswords=sshdIfDisablePermitEmptyPasswords,sshdIfDisablePermitUserEnvironment=sshdIfDisablePermitUserEnvironment,sshdIfSpecificMACs=sshdIfSpecificMACs,sshdIfSetClientAliveInterval=sshdIfSetClientAliveInterval,sshdIfSetLoginGraceTime=sshdIfSetLoginGraceTime,pamPwqualityconfIfExist=pamPwqualityconfIfExist,pamIfSetMinlen=pamIfSetMinlen,pamIfSetMinclass=pamIfSetMinclass,sshdSetedLockAndUnlockTimeFiles=sshdSetedLockAndUnlockTimeFiles,sshdNotSetedLockAndUnlockTimeFiles=sshdNotSetedLockAndUnlockTimeFiles,sshdPamdFileArray=sshdPamdFileArray,sshdPamdFileReuseLimitArray=sshdPamdFileReuseLimitArray,sshdPamdFileIfSetSha512Array=sshdPamdFileIfSetSha512Array,accountPassMaxDays=accountPassMaxDays,accountPassMinDays=accountPassMinDays,accountPassWarnDays=accountPassWarnDays,accountPassAutolockInactiveDays=accountPassAutolockInactiveDays,accountShouldUnloginArray=accountShouldUnloginArray,accountGIDOfRoot=accountGIDOfRoot,accountProfileFileArray=accountProfileFileArray,accountProfileTMOUTArray=accountProfileTMOUTArray,accountIfSetUsersCanAccessSuCommand=accountIfSetUsersCanAccessSuCommand,importantFilenameArray=importantFilenameArray,importantFilePermissionArray=importantFilePermissionArray,importantFileUidgidArray=importantFileUidgidArray,userIfSetPasswdOrArray=userIfSetPasswdOrArray,uid0OnlyRootOrArray=uid0OnlyRootOrArray,pathDirIfNotHasDot=pathDirIfNotHasDot,pathDirPermissionHasGWArray=pathDirPermissionHasGWArray,pathDirPermissionHasOWArray=pathDirPermissionHasOWArray,pathDirOwnerIsNotRootArray=pathDirOwnerIsNotRootArray,pathDirDoesNotExistOrNotDirArray=pathDirDoesNotExistOrNotDirArray,userArray=userArray,userHomeDirIfExistArray=userHomeDirIfExistArray,userHomeDirPermissionArray=userHomeDirPermissionArray,userIfOwnTheirHomeDirArray=userIfOwnTheirHomeDirArray,userHomeDirIfHasGWorOWDotFileArray=userHomeDirIfHasGWorOWDotFileArray,userHomeDirIfHasOtherFileArray=userHomeDirIfHasOtherFileArray,groupNotExistInetcgroup=groupNotExistInetcgroup,usersIfHasUniqueUIDArray=usersIfHasUniqueUIDArray,groupsIfHasUniqueGIDArray=groupsIfHasUniqueGIDArray) File "/opt/py3/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(args, kwargs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 538, in get_or_create return self.get(kwargs), False File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 399, in get clone = self.filter(*args, *kwargs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 892, in filter return self._filter_or_exclude(False, args, kwargs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/query.py", line 910, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs)) File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1290, in addq clause, = self._add_q(q_object, self.used_aliases) File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1318, in _add_q split_subq=split_subq, simple_col=simple_col, File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1251, in build_filter condition = self.build_lookup(lookups, col, value) File "/opt/py3/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1116, in build_lookup lookup = lookup_class(lhs, rhs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/lookups.py", line 20, in init self.rhs = self.get_prep_lookup() File "/opt/py3/lib/python3.6/site-packages/django/db/models/lookups.py", line 70, in get_prep_lookup return self.lhs.output_field.get_prep_value(self.rhs) File "/opt/py3/lib/python3.6/site-packages/django/db/models/fields/init.py", line 1018, in get_prep_value return self.to_python(value) File "/opt/py3/lib/python3.6/site-packages/django/db/models/fields/init.py", line 1011, in to_python params={'value': value}, django.core.exceptions.ValidationError: ['’‘ 必须为 True 或者 False。']

yq513 commented 4 years ago

[root@zhx-app db]# find / -name LinuxScanResMet.db /usr/share/ibus-libpinyin/db/LinuxScanResMet.db [root@zhx-app db]# cd /usr/share/ibus-libpinyin/db [root@zhx-app db]# ll 总用量 1496 -rw-r--r--. 1 root root 834560 6月 10 2014 english.db -rw-r--r-- 1 root root 0 2月 14 20:16 LinuxScanResMet.db -rw-r--r--. 1 root root 695296 6月 10 2014 strokes.db [root@zhx-app db]# 去目录看这个数据库, 我装的sqlite3 没装好?

chroblert commented 4 years ago

数据库是db.sqlite3,在后端服务器上。我试了下代码,找到了一些问题,正在修复

发件人: yq513 发送时间: 2020年2月14日 20:35 收件人: chroblert/AssetManage 抄送: jerrybird; Comment 主题: Re: [chroblert/AssetManage] 后端提示错误,Internal Server Error: /baseline/linux_scan_res_report/ (#6)

[root@zhx-app db]# find / -name LinuxScanResMet.db /usr/share/ibus-libpinyin/db/LinuxScanResMet.db [root@zhx-app db]# cd /usr/share/ibus-libpinyin/db [root@zhx-app db]# ll 总用量 1496 -rw-r--r--. 1 root root 834560 6月 10 2014 english.db -rw-r--r-- 1 root root 0 2月 14 20:16 LinuxScanResMet.db -rw-r--r--. 1 root root 695296 6月 10 2014 strokes.db [root@zhx-app db]# 去目录看这个数据库, 我装的sqlite3 没装好? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

chroblert commented 4 years ago

已将修复,并将agent都放在了这个项目中,请看看还有没刚刚的问题

yq513 commented 4 years ago

已将修复,重新代理都放在了这个项目中,请看看还有没刚刚的问题

刚测试,已经没有了。

要是有空的话增加一些功能,例如检查结果报表导出,删除检查记录,可能更好些。纯属建议 不必当真。laizikaishi@163.com