Fossil SCM
Show the age of phantoms. Provide text hints on how to deal with phantoms on the /secaudit0 page.
Commit
97cac02b8a1a4cd75d43c7f8350d1f6646af6886d40d3b9b10c92499022ef842
Parent
cf72fc18e74ac41…
2 files changed
+15
-3
+6
+15
-3
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -1416,31 +1416,43 @@ | ||
| 1416 | 1416 | ** Output HTML that shows a table of all public phantoms. |
| 1417 | 1417 | */ |
| 1418 | 1418 | void table_of_public_phantoms(void){ |
| 1419 | 1419 | Stmt q; |
| 1420 | 1420 | char *zRange; |
| 1421 | + double rNow; | |
| 1421 | 1422 | zRange = mprintf("IN (SELECT rid FROM phantom EXCEPT" |
| 1422 | 1423 | " SELECT rid FROM private)"); |
| 1423 | 1424 | describe_artifacts(zRange); |
| 1424 | 1425 | fossil_free(zRange); |
| 1425 | 1426 | 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)" | |
| 1427 | 1430 | " FROM description ORDER BY rid" |
| 1428 | 1431 | ); |
| 1432 | + rNow = db_double(0.0, "SELECT julianday('now')"); | |
| 1429 | 1433 | @ <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 | |
| 1431 | 1435 | while( db_step(&q)==SQLITE_ROW ){ |
| 1432 | 1436 | int rid = db_column_int(&q,0); |
| 1433 | 1437 | const char *zUuid = db_column_text(&q, 1); |
| 1434 | 1438 | const char *zDesc = db_column_text(&q, 2); |
| 1435 | 1439 | const char *zRef = db_column_text(&q,3); |
| 1440 | + double mtime = db_column_double(&q,4); | |
| 1436 | 1441 | @ <tr><td valign="top">%d(rid)</td> |
| 1437 | 1442 | @ <td valign="top" align="left">%h(zUuid)<br>%h(zDesc)</td> |
| 1438 | 1443 | if( zRef && zRef[0] ){ |
| 1439 | 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> | |
| 1451 | + } | |
| 1440 | 1452 | }else{ |
| 1441 | - @ <td> | |
| 1453 | + @ <td> <td> | |
| 1442 | 1454 | } |
| 1443 | 1455 | @ </tr> |
| 1444 | 1456 | } |
| 1445 | 1457 | @ </table> |
| 1446 | 1458 | db_finalize(&q); |
| 1447 | 1459 |
| --- 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> |
| 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> |
| 1451 | } |
| 1452 | }else{ |
| 1453 | @ <td> <td> |
| 1454 | } |
| 1455 | @ </tr> |
| 1456 | } |
| 1457 | @ </table> |
| 1458 | db_finalize(&q); |
| 1459 |
+6
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -579,10 +579,16 @@ | ||
| 579 | 579 | @ Phantom artifacts are artifacts whose hash name is referenced by some |
| 580 | 580 | @ other artifact but whose content is unknown. Some phantoms are marked |
| 581 | 581 | @ private and those are ignored. But public phantoms cause unnecessary |
| 582 | 582 | @ sync traffic and might represent malicious attempts to corrupt the |
| 583 | 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> | |
| 584 | 590 | @ </p> |
| 585 | 591 | table_of_public_phantoms(); |
| 586 | 592 | @ </li> |
| 587 | 593 | } |
| 588 | 594 | |
| 589 | 595 |
| --- 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 |