Fossil SCM

Add SQL errors as a new logfile message category.

drh 2025-06-23 13:53 trunk
Commit e3c6e011be2c84ee6d2240368325d5d5422e14788e87b62d2b8a85d6b152e98a
1 file changed +15 -2
--- src/security_audit.c
+++ src/security_audit.c
@@ -830,10 +830,11 @@
830830
** y=0x004 Show hung backoffice processes
831831
** y=0x008 Show POST requests from a different origin
832832
** y=0x010 Show SQLITE_AUTH and similar
833833
** y=0x020 Show SMTP error reports
834834
** y=0x040 Show TH1 vulnerability reports
835
+** y=0x080 Show SQL errors
835836
** y=0x800 Show other uncategorized messages
836837
**
837838
** If y is omitted or is zero, a count of the various message types is
838839
** shown.
839840
*/
@@ -840,11 +841,11 @@
840841
void errorlog_page(void){
841842
i64 szFile;
842843
FILE *in;
843844
char *zLog;
844845
const char *zType = P("y");
845
- static const int eAllTypes = 0x87f;
846
+ static const int eAllTypes = 0x8ff;
846847
long eType = 0;
847848
int bOutput = 0;
848849
int prevWasTime = 0;
849850
int nHack = 0;
850851
int nPanic = 0;
@@ -852,10 +853,11 @@
852853
int nHang = 0;
853854
int nXPost = 0;
854855
int nAuth = 0;
855856
int nSmtp = 0;
856857
int nVuln = 0;
858
+ int nSqlErr = 0;
857859
char z[10000];
858860
char zTime[10000];
859861
860862
login_check_credentials();
861863
if( !g.perm.Admin ){
@@ -933,10 +935,13 @@
933935
if( eType & 0x20 ){
934936
@ <li>SMTP malfunctions
935937
}
936938
if( eType & 0x40 ){
937939
@ <li>TH1 vulnerabilities
940
+ }
941
+ if( eType & 0x80 ){
942
+ @ <li>SQL errors
938943
}
939944
if( eType & 0x800 ){
940945
@ <li>Other uncategorized messages
941946
}
942947
@ </ul>
@@ -975,10 +980,14 @@
975980
}else
976981
if( strncmp(z,"possible", 8)==0 && strstr(z,"tainted")!=0 ){
977982
bOutput = (eType & 0x40)!=0;
978983
nVuln++;
979984
}else
985
+ if( strstr(z,"statement aborts at ") ){
986
+ bOutput = (eType & 0x80)!=0;
987
+ nSqlErr++;
988
+ }else
980989
{
981990
bOutput = (eType & 0x800)!=0;
982991
nOther++;
983992
}
984993
if( bOutput ){
@@ -1000,11 +1009,11 @@
10001009
fclose(in);
10011010
if( eType ){
10021011
@ </pre>
10031012
}
10041013
if( eType==0 ){
1005
- int nNonHack = nPanic + nHang + nAuth + nSmtp + nVuln + nOther;
1014
+ int nNonHack = nPanic + nHang + nAuth + nSmtp + nVuln + nOther + nSqlErr;
10061015
int nTotal = nNonHack + nHack + nXPost;
10071016
@ <p><table border="a" cellspacing="0" cellpadding="5">
10081017
if( nPanic>0 ){
10091018
@ <tr><td align="right">%d(nPanic)</td>
10101019
@ <td><a href="./errorlog?y=2">Panics</a></td>
@@ -1015,10 +1024,14 @@
10151024
}
10161025
if( nHack>0 ){
10171026
@ <tr><td align="right">%d(nHack)</td>
10181027
@ <td><a href="./errorlog?y=1">Hack Attempts</a></td>
10191028
}
1029
+ if( nSqlErr>0 ){
1030
+ @ <tr><td align="right">%d(nSqlErr)</td>
1031
+ @ <td><a href="./errorlog?y=128">SQL Errors</a></td>
1032
+ }
10201033
if( nHang>0 ){
10211034
@ <tr><td align="right">%d(nHang)</td>
10221035
@ <td><a href="./errorlog?y=4">Hung Backoffice</a></td>
10231036
}
10241037
if( nXPost>0 ){
10251038
--- src/security_audit.c
+++ src/security_audit.c
@@ -830,10 +830,11 @@
830 ** y=0x004 Show hung backoffice processes
831 ** y=0x008 Show POST requests from a different origin
832 ** y=0x010 Show SQLITE_AUTH and similar
833 ** y=0x020 Show SMTP error reports
834 ** y=0x040 Show TH1 vulnerability reports
 
835 ** y=0x800 Show other uncategorized messages
836 **
837 ** If y is omitted or is zero, a count of the various message types is
838 ** shown.
839 */
@@ -840,11 +841,11 @@
840 void errorlog_page(void){
841 i64 szFile;
842 FILE *in;
843 char *zLog;
844 const char *zType = P("y");
845 static const int eAllTypes = 0x87f;
846 long eType = 0;
847 int bOutput = 0;
848 int prevWasTime = 0;
849 int nHack = 0;
850 int nPanic = 0;
@@ -852,10 +853,11 @@
852 int nHang = 0;
853 int nXPost = 0;
854 int nAuth = 0;
855 int nSmtp = 0;
856 int nVuln = 0;
 
857 char z[10000];
858 char zTime[10000];
859
860 login_check_credentials();
861 if( !g.perm.Admin ){
@@ -933,10 +935,13 @@
933 if( eType & 0x20 ){
934 @ <li>SMTP malfunctions
935 }
936 if( eType & 0x40 ){
937 @ <li>TH1 vulnerabilities
 
 
 
938 }
939 if( eType & 0x800 ){
940 @ <li>Other uncategorized messages
941 }
942 @ </ul>
@@ -975,10 +980,14 @@
975 }else
976 if( strncmp(z,"possible", 8)==0 && strstr(z,"tainted")!=0 ){
977 bOutput = (eType & 0x40)!=0;
978 nVuln++;
979 }else
 
 
 
 
980 {
981 bOutput = (eType & 0x800)!=0;
982 nOther++;
983 }
984 if( bOutput ){
@@ -1000,11 +1009,11 @@
1000 fclose(in);
1001 if( eType ){
1002 @ </pre>
1003 }
1004 if( eType==0 ){
1005 int nNonHack = nPanic + nHang + nAuth + nSmtp + nVuln + nOther;
1006 int nTotal = nNonHack + nHack + nXPost;
1007 @ <p><table border="a" cellspacing="0" cellpadding="5">
1008 if( nPanic>0 ){
1009 @ <tr><td align="right">%d(nPanic)</td>
1010 @ <td><a href="./errorlog?y=2">Panics</a></td>
@@ -1015,10 +1024,14 @@
1015 }
1016 if( nHack>0 ){
1017 @ <tr><td align="right">%d(nHack)</td>
1018 @ <td><a href="./errorlog?y=1">Hack Attempts</a></td>
1019 }
 
 
 
 
1020 if( nHang>0 ){
1021 @ <tr><td align="right">%d(nHang)</td>
1022 @ <td><a href="./errorlog?y=4">Hung Backoffice</a></td>
1023 }
1024 if( nXPost>0 ){
1025
--- src/security_audit.c
+++ src/security_audit.c
@@ -830,10 +830,11 @@
830 ** y=0x004 Show hung backoffice processes
831 ** y=0x008 Show POST requests from a different origin
832 ** y=0x010 Show SQLITE_AUTH and similar
833 ** y=0x020 Show SMTP error reports
834 ** y=0x040 Show TH1 vulnerability reports
835 ** y=0x080 Show SQL errors
836 ** y=0x800 Show other uncategorized messages
837 **
838 ** If y is omitted or is zero, a count of the various message types is
839 ** shown.
840 */
@@ -840,11 +841,11 @@
841 void errorlog_page(void){
842 i64 szFile;
843 FILE *in;
844 char *zLog;
845 const char *zType = P("y");
846 static const int eAllTypes = 0x8ff;
847 long eType = 0;
848 int bOutput = 0;
849 int prevWasTime = 0;
850 int nHack = 0;
851 int nPanic = 0;
@@ -852,10 +853,11 @@
853 int nHang = 0;
854 int nXPost = 0;
855 int nAuth = 0;
856 int nSmtp = 0;
857 int nVuln = 0;
858 int nSqlErr = 0;
859 char z[10000];
860 char zTime[10000];
861
862 login_check_credentials();
863 if( !g.perm.Admin ){
@@ -933,10 +935,13 @@
935 if( eType & 0x20 ){
936 @ <li>SMTP malfunctions
937 }
938 if( eType & 0x40 ){
939 @ <li>TH1 vulnerabilities
940 }
941 if( eType & 0x80 ){
942 @ <li>SQL errors
943 }
944 if( eType & 0x800 ){
945 @ <li>Other uncategorized messages
946 }
947 @ </ul>
@@ -975,10 +980,14 @@
980 }else
981 if( strncmp(z,"possible", 8)==0 && strstr(z,"tainted")!=0 ){
982 bOutput = (eType & 0x40)!=0;
983 nVuln++;
984 }else
985 if( strstr(z,"statement aborts at ") ){
986 bOutput = (eType & 0x80)!=0;
987 nSqlErr++;
988 }else
989 {
990 bOutput = (eType & 0x800)!=0;
991 nOther++;
992 }
993 if( bOutput ){
@@ -1000,11 +1009,11 @@
1009 fclose(in);
1010 if( eType ){
1011 @ </pre>
1012 }
1013 if( eType==0 ){
1014 int nNonHack = nPanic + nHang + nAuth + nSmtp + nVuln + nOther + nSqlErr;
1015 int nTotal = nNonHack + nHack + nXPost;
1016 @ <p><table border="a" cellspacing="0" cellpadding="5">
1017 if( nPanic>0 ){
1018 @ <tr><td align="right">%d(nPanic)</td>
1019 @ <td><a href="./errorlog?y=2">Panics</a></td>
@@ -1015,10 +1024,14 @@
1024 }
1025 if( nHack>0 ){
1026 @ <tr><td align="right">%d(nHack)</td>
1027 @ <td><a href="./errorlog?y=1">Hack Attempts</a></td>
1028 }
1029 if( nSqlErr>0 ){
1030 @ <tr><td align="right">%d(nSqlErr)</td>
1031 @ <td><a href="./errorlog?y=128">SQL Errors</a></td>
1032 }
1033 if( nHang>0 ){
1034 @ <tr><td align="right">%d(nHang)</td>
1035 @ <td><a href="./errorlog?y=4">Hung Backoffice</a></td>
1036 }
1037 if( nXPost>0 ){
1038

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button