Fossil SCM

Show the age of phantoms. Provide text hints on how to deal with phantoms on the /secaudit0 page.

drh 2020-11-12 14:25 trunk
Commit 97cac02b8a1a4cd75d43c7f8350d1f6646af6886d40d3b9b10c92499022ef842
+15 -3
--- src/name.c
+++ src/name.c
@@ -1416,31 +1416,43 @@
14161416
** Output HTML that shows a table of all public phantoms.
14171417
*/
14181418
void table_of_public_phantoms(void){
14191419
Stmt q;
14201420
char *zRange;
1421
+ double rNow;
14211422
zRange = mprintf("IN (SELECT rid FROM phantom EXCEPT"
14221423
" SELECT rid FROM private)");
14231424
describe_artifacts(zRange);
14241425
fossil_free(zRange);
14251426
db_prepare(&q,
1426
- "SELECT rid, uuid, summary, ref"
1427
+ "SELECT rid, uuid, summary, ref,"
1428
+ " (SELECT mtime FROM blob, rcvfrom"
1429
+ " WHERE blob.uuid=ref AND rcvfrom.rcvid=blob.rcvid)"
14271430
" FROM description ORDER BY rid"
14281431
);
1432
+ rNow = db_double(0.0, "SELECT julianday('now')");
14291433
@ <table cellpadding="2" cellspacing="0" border="1">
1430
- @ <tr><th>RID<th>Description<th>Source
1434
+ @ <tr><th>RID<th>Description<th>Source<th>Age
14311435
while( db_step(&q)==SQLITE_ROW ){
14321436
int rid = db_column_int(&q,0);
14331437
const char *zUuid = db_column_text(&q, 1);
14341438
const char *zDesc = db_column_text(&q, 2);
14351439
const char *zRef = db_column_text(&q,3);
1440
+ double mtime = db_column_double(&q,4);
14361441
@ <tr><td valign="top">%d(rid)</td>
14371442
@ <td valign="top" align="left">%h(zUuid)<br>%h(zDesc)</td>
14381443
if( zRef && zRef[0] ){
14391444
@ <td valign="top">%z(href("%R/info/%!S",zRef))%!S(zRef)</a>
1445
+ if( mtime>0 ){
1446
+ char *zAge = human_readable_age(rNow - mtime);
1447
+ @ <td valign="top">%h(zAge)
1448
+ fossil_free(zAge);
1449
+ }else{
1450
+ @ <td>&nbsp;
1451
+ }
14401452
}else{
1441
- @ <td>&nbsp;
1453
+ @ <td>&nbsp;<td>&nbsp;
14421454
}
14431455
@ </tr>
14441456
}
14451457
@ </table>
14461458
db_finalize(&q);
14471459
--- src/name.c
+++ src/name.c
@@ -1416,31 +1416,43 @@
1416 ** Output HTML that shows a table of all public phantoms.
1417 */
1418 void table_of_public_phantoms(void){
1419 Stmt q;
1420 char *zRange;
 
1421 zRange = mprintf("IN (SELECT rid FROM phantom EXCEPT"
1422 " SELECT rid FROM private)");
1423 describe_artifacts(zRange);
1424 fossil_free(zRange);
1425 db_prepare(&q,
1426 "SELECT rid, uuid, summary, ref"
 
 
1427 " FROM description ORDER BY rid"
1428 );
 
1429 @ <table cellpadding="2" cellspacing="0" border="1">
1430 @ <tr><th>RID<th>Description<th>Source
1431 while( db_step(&q)==SQLITE_ROW ){
1432 int rid = db_column_int(&q,0);
1433 const char *zUuid = db_column_text(&q, 1);
1434 const char *zDesc = db_column_text(&q, 2);
1435 const char *zRef = db_column_text(&q,3);
 
1436 @ <tr><td valign="top">%d(rid)</td>
1437 @ <td valign="top" align="left">%h(zUuid)<br>%h(zDesc)</td>
1438 if( zRef && zRef[0] ){
1439 @ <td valign="top">%z(href("%R/info/%!S",zRef))%!S(zRef)</a>
 
 
 
 
 
 
 
1440 }else{
1441 @ <td>&nbsp;
1442 }
1443 @ </tr>
1444 }
1445 @ </table>
1446 db_finalize(&q);
1447
--- src/name.c
+++ src/name.c
@@ -1416,31 +1416,43 @@
1416 ** Output HTML that shows a table of all public phantoms.
1417 */
1418 void table_of_public_phantoms(void){
1419 Stmt q;
1420 char *zRange;
1421 double rNow;
1422 zRange = mprintf("IN (SELECT rid FROM phantom EXCEPT"
1423 " SELECT rid FROM private)");
1424 describe_artifacts(zRange);
1425 fossil_free(zRange);
1426 db_prepare(&q,
1427 "SELECT rid, uuid, summary, ref,"
1428 " (SELECT mtime FROM blob, rcvfrom"
1429 " WHERE blob.uuid=ref AND rcvfrom.rcvid=blob.rcvid)"
1430 " FROM description ORDER BY rid"
1431 );
1432 rNow = db_double(0.0, "SELECT julianday('now')");
1433 @ <table cellpadding="2" cellspacing="0" border="1">
1434 @ <tr><th>RID<th>Description<th>Source<th>Age
1435 while( db_step(&q)==SQLITE_ROW ){
1436 int rid = db_column_int(&q,0);
1437 const char *zUuid = db_column_text(&q, 1);
1438 const char *zDesc = db_column_text(&q, 2);
1439 const char *zRef = db_column_text(&q,3);
1440 double mtime = db_column_double(&q,4);
1441 @ <tr><td valign="top">%d(rid)</td>
1442 @ <td valign="top" align="left">%h(zUuid)<br>%h(zDesc)</td>
1443 if( zRef && zRef[0] ){
1444 @ <td valign="top">%z(href("%R/info/%!S",zRef))%!S(zRef)</a>
1445 if( mtime>0 ){
1446 char *zAge = human_readable_age(rNow - mtime);
1447 @ <td valign="top">%h(zAge)
1448 fossil_free(zAge);
1449 }else{
1450 @ <td>&nbsp;
1451 }
1452 }else{
1453 @ <td>&nbsp;<td>&nbsp;
1454 }
1455 @ </tr>
1456 }
1457 @ </table>
1458 db_finalize(&q);
1459
--- src/security_audit.c
+++ src/security_audit.c
@@ -579,10 +579,16 @@
579579
@ Phantom artifacts are artifacts whose hash name is referenced by some
580580
@ other artifact but whose content is unknown. Some phantoms are marked
581581
@ private and those are ignored. But public phantoms cause unnecessary
582582
@ sync traffic and might represent malicious attempts to corrupt the
583583
@ repository structure.
584
+ @ </p><p>
585
+ @ To suppress unnecessary sync traffic caused by phantoms, add the RID
586
+ @ of each phantom to the "private" table. Example:
587
+ @ <blockquote><pre>
588
+ @ INSERT INTO private SELECT rid FROM blob WHERE content IS NULL;
589
+ @ </pre></blockquote>
584590
@ </p>
585591
table_of_public_phantoms();
586592
@ </li>
587593
}
588594
589595
--- src/security_audit.c
+++ src/security_audit.c
@@ -579,10 +579,16 @@
579 @ Phantom artifacts are artifacts whose hash name is referenced by some
580 @ other artifact but whose content is unknown. Some phantoms are marked
581 @ private and those are ignored. But public phantoms cause unnecessary
582 @ sync traffic and might represent malicious attempts to corrupt the
583 @ repository structure.
 
 
 
 
 
 
584 @ </p>
585 table_of_public_phantoms();
586 @ </li>
587 }
588
589
--- src/security_audit.c
+++ src/security_audit.c
@@ -579,10 +579,16 @@
579 @ Phantom artifacts are artifacts whose hash name is referenced by some
580 @ other artifact but whose content is unknown. Some phantoms are marked
581 @ private and those are ignored. But public phantoms cause unnecessary
582 @ sync traffic and might represent malicious attempts to corrupt the
583 @ repository structure.
584 @ </p><p>
585 @ To suppress unnecessary sync traffic caused by phantoms, add the RID
586 @ of each phantom to the "private" table. Example:
587 @ <blockquote><pre>
588 @ INSERT INTO private SELECT rid FROM blob WHERE content IS NULL;
589 @ </pre></blockquote>
590 @ </p>
591 table_of_public_phantoms();
592 @ </li>
593 }
594
595

Keyboard Shortcuts

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