Hex Artifact Content
Not logged in

Artifact 5ce55378d67f55956debb8a9cad8df56186ec61a:

File src/shun.c part of check-in [0be54823ba] - Add defenses against cross-site request forgery attacks. by drh on 2008-10-18 12:55:44.

0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20  /*.** Copyright 
0010: 28 63 29 20 32 30 30 38 20 44 2e 20 52 69 63 68  (c) 2008 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54  ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66  his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f  ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75  u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20  te it and/or.** 
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20  modify it under 
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65  the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62   GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76  lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c  ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65  ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69  ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73  s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20  tributed in the 
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c  hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20  l be useful,.** 
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20  but WITHOUT ANY 
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75  WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69  t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a  ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54  * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52  Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55   A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20  RPOSE.  See the 
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50  GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f  ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a  r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c  ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20  d have received 
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e  a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63  U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e  .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72  g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69  ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65  te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20  ation, Inc., 59 
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53  Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73  uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31  ton, MA  02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20  307, USA..**.** 
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69  Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20  nformation:.**  
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a   drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68  *   http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a  waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0360: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 66 69 6c 65  .**.** This file
0370: 20 63 6f 6e 74 61 69 6e 73 20 63 6f 64 65 20 75   contains code u
0380: 73 65 64 20 74 6f 20 6d 61 6e 61 67 65 20 53 48  sed to manage SH
0390: 55 4e 20 74 61 62 6c 65 20 6f 66 20 74 68 65 20  UN table of the 
03a0: 72 65 70 6f 73 69 74 6f 72 79 0a 2a 2f 0a 23 69  repository.*/.#i
03b0: 6e 63 6c 75 64 65 20 22 63 6f 6e 66 69 67 2e 68  nclude "config.h
03c0: 22 0a 23 69 6e 63 6c 75 64 65 20 22 73 68 75 6e  ".#include "shun
03d0: 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73  .h".#include <as
03e0: 73 65 72 74 2e 68 3e 0a 0a 2f 2a 0a 2a 2a 20 52  sert.h>../*.** R
03f0: 65 74 75 72 6e 20 74 72 75 65 20 69 66 20 74 68  eturn true if th
0400: 65 20 67 69 76 65 6e 20 55 55 49 44 20 73 68 6f  e given UUID sho
0410: 75 6c 64 20 62 65 20 73 68 75 6e 6e 65 64 2e 0a  uld be shunned..
0420: 2a 2f 0a 69 6e 74 20 75 75 69 64 5f 69 73 5f 73  */.int uuid_is_s
0430: 68 75 6e 6e 65 64 28 63 6f 6e 73 74 20 63 68 61  hunned(const cha
0440: 72 20 2a 7a 55 75 69 64 29 7b 0a 20 20 73 74 61  r *zUuid){.  sta
0450: 74 69 63 20 53 74 6d 74 20 71 3b 0a 20 20 69 6e  tic Stmt q;.  in
0460: 74 20 72 63 3b 0a 20 20 69 66 28 20 7a 55 75 69  t rc;.  if( zUui
0470: 64 3d 3d 30 20 7c 7c 20 7a 55 75 69 64 5b 30 5d  d==0 || zUuid[0]
0480: 3d 3d 30 20 29 20 72 65 74 75 72 6e 20 30 3b 0a  ==0 ) return 0;.
0490: 20 20 64 62 5f 73 74 61 74 69 63 5f 70 72 65 70    db_static_prep
04a0: 61 72 65 28 26 71 2c 20 22 53 45 4c 45 43 54 20  are(&q, "SELECT 
04b0: 31 20 46 52 4f 4d 20 73 68 75 6e 20 57 48 45 52  1 FROM shun WHER
04c0: 45 20 75 75 69 64 3d 3a 75 75 69 64 22 29 3b 0a  E uuid=:uuid");.
04d0: 20 20 64 62 5f 62 69 6e 64 5f 74 65 78 74 28 26    db_bind_text(&
04e0: 71 2c 20 22 3a 75 75 69 64 22 2c 20 7a 55 75 69  q, ":uuid", zUui
04f0: 64 29 3b 0a 20 20 72 63 20 3d 20 64 62 5f 73 74  d);.  rc = db_st
0500: 65 70 28 26 71 29 3b 0a 20 20 64 62 5f 72 65 73  ep(&q);.  db_res
0510: 65 74 28 26 71 29 3b 0a 20 20 72 65 74 75 72 6e  et(&q);.  return
0520: 20 72 63 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 3b   rc==SQLITE_ROW;
0530: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 57 45 42 50 41 47  .}../*.** WEBPAG
0540: 45 3a 20 73 68 75 6e 0a 2a 2f 0a 76 6f 69 64 20  E: shun.*/.void 
0550: 73 68 75 6e 5f 70 61 67 65 28 76 6f 69 64 29 7b  shun_page(void){
0560: 0a 20 20 53 74 6d 74 20 71 3b 0a 20 20 69 6e 74  .  Stmt q;.  int
0570: 20 63 6e 74 20 3d 20 30 3b 0a 20 20 63 6f 6e 73   cnt = 0;.  cons
0580: 74 20 63 68 61 72 20 2a 7a 55 75 69 64 20 3d 20  t char *zUuid = 
0590: 50 28 22 75 75 69 64 22 29 3b 0a 20 20 69 6e 74  P("uuid");.  int
05a0: 20 6e 55 75 69 64 3b 0a 20 20 63 68 61 72 20 7a   nUuid;.  char z
05b0: 43 61 6e 6f 6e 69 63 61 6c 5b 55 55 49 44 5f 53  Canonical[UUID_S
05c0: 49 5a 45 2b 31 5d 3b 0a 0a 20 20 6c 6f 67 69 6e  IZE+1];..  login
05d0: 5f 63 68 65 63 6b 5f 63 72 65 64 65 6e 74 69 61  _check_credentia
05e0: 6c 73 28 29 3b 0a 20 20 69 66 28 20 21 67 2e 6f  ls();.  if( !g.o
05f0: 6b 41 64 6d 69 6e 20 29 7b 0a 20 20 20 20 6c 6f  kAdmin ){.    lo
0600: 67 69 6e 5f 6e 65 65 64 65 64 28 29 3b 0a 20 20  gin_needed();.  
0610: 7d 0a 20 20 69 66 28 20 7a 55 75 69 64 20 29 7b  }.  if( zUuid ){
0620: 0a 20 20 20 20 6e 55 75 69 64 20 3d 20 73 74 72  .    nUuid = str
0630: 6c 65 6e 28 7a 55 75 69 64 29 3b 0a 20 20 20 20  len(zUuid);.    
0640: 69 66 28 20 6e 55 75 69 64 21 3d 34 30 20 7c 7c  if( nUuid!=40 ||
0650: 20 21 76 61 6c 69 64 61 74 65 31 36 28 7a 55 75   !validate16(zUu
0660: 69 64 2c 20 6e 55 75 69 64 29 20 29 7b 0a 20 20  id, nUuid) ){.  
0670: 20 20 20 20 7a 55 75 69 64 20 3d 20 30 3b 0a 20      zUuid = 0;. 
0680: 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20     }else{.      
0690: 6d 65 6d 63 70 79 28 7a 43 61 6e 6f 6e 69 63 61  memcpy(zCanonica
06a0: 6c 2c 20 7a 55 75 69 64 2c 20 55 55 49 44 5f 53  l, zUuid, UUID_S
06b0: 49 5a 45 2b 31 29 3b 0a 20 20 20 20 20 20 63 61  IZE+1);.      ca
06c0: 6e 6f 6e 69 63 61 6c 31 36 28 7a 43 61 6e 6f 6e  nonical16(zCanon
06d0: 69 63 61 6c 2c 20 55 55 49 44 5f 53 49 5a 45 29  ical, UUID_SIZE)
06e0: 3b 0a 20 20 20 20 20 20 7a 55 75 69 64 20 3d 20  ;.      zUuid = 
06f0: 7a 43 61 6e 6f 6e 69 63 61 6c 3b 0a 20 20 20 20  zCanonical;.    
0700: 7d 0a 20 20 7d 0a 20 20 73 74 79 6c 65 5f 68 65  }.  }.  style_he
0710: 61 64 65 72 28 22 53 68 75 6e 6e 65 64 20 41 72  ader("Shunned Ar
0720: 74 69 66 61 63 74 73 22 29 3b 0a 20 20 69 66 28  tifacts");.  if(
0730: 20 7a 55 75 69 64 20 26 26 20 50 28 22 73 75 62   zUuid && P("sub
0740: 22 29 20 29 7b 0a 20 20 20 20 6c 6f 67 69 6e 5f  ") ){.    login_
0750: 76 65 72 69 66 79 5f 63 73 72 66 5f 73 65 63 72  verify_csrf_secr
0760: 65 74 28 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c  et();.    db_mul
0770: 74 69 5f 65 78 65 63 28 22 44 45 4c 45 54 45 20  ti_exec("DELETE 
0780: 46 52 4f 4d 20 73 68 75 6e 20 57 48 45 52 45 20  FROM shun WHERE 
0790: 75 75 69 64 3d 27 25 73 27 22 2c 20 7a 55 75 69  uuid='%s'", zUui
07a0: 64 29 3b 0a 20 20 20 20 69 66 28 20 64 62 5f 65  d);.    if( db_e
07b0: 78 69 73 74 73 28 22 53 45 4c 45 43 54 20 31 20  xists("SELECT 1 
07c0: 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 20  FROM blob WHERE 
07d0: 75 75 69 64 3d 27 25 73 27 22 2c 20 7a 55 75 69  uuid='%s'", zUui
07e0: 64 29 20 29 7b 0a 20 20 20 20 20 20 40 20 3c 70  d) ){.      @ <p
07f0: 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 62 6c  ><font color="bl
0800: 75 65 22 3e 41 72 74 69 66 61 63 74 20 0a 20 20  ue">Artifact .  
0810: 20 20 20 20 40 20 3c 61 20 68 72 65 66 3d 22 25      @ <a href="%
0820: 73 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72  s(g.zBaseURL)/ar
0830: 74 69 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29  tifact/%s(zUuid)
0840: 22 3e 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20  ">%s(zUuid)</a> 
0850: 69 73 20 6e 6f 0a 20 20 20 20 20 20 40 20 6c 6f  is no.      @ lo
0860: 6e 67 65 72 20 62 65 69 6e 67 20 73 68 75 6e 6e  nger being shunn
0870: 65 64 2e 3c 2f 66 6f 6e 74 3e 3c 2f 70 3e 0a 20  ed.</font></p>. 
0880: 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20     }else{.      
0890: 40 20 3c 70 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72  @ <p><font color
08a0: 3d 22 62 6c 75 65 22 3e 41 72 74 69 66 61 63 74  ="blue">Artifact
08b0: 20 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20 77   %s(zUuid)</a> w
08c0: 69 6c 6c 20 6e 6f 20 6c 6f 6e 67 65 72 0a 20 20  ill no longer.  
08d0: 20 20 20 20 40 20 62 65 20 73 68 75 6e 6e 65 64      @ be shunned
08e0: 2e 20 20 42 75 74 20 69 74 20 64 6f 65 73 20 6e  .  But it does n
08f0: 6f 74 20 65 78 69 73 74 20 69 6e 20 74 68 65 20  ot exist in the 
0900: 72 65 70 6f 73 69 74 6f 72 79 2e 20 20 49 74 0a  repository.  It.
0910: 20 20 20 20 20 20 40 20 6d 61 79 20 62 65 20 6e        @ may be n
0920: 65 63 65 73 73 61 72 79 20 74 6f 20 72 65 62 75  ecessary to rebu
0930: 69 6c 64 20 74 68 65 20 72 65 70 6f 73 69 74 6f  ild the reposito
0940: 72 79 20 75 73 69 6e 67 20 74 68 65 0a 20 20 20  ry using the.   
0950: 20 20 20 40 20 3c 62 3e 66 6f 73 73 69 6c 20 72     @ <b>fossil r
0960: 65 62 75 69 6c 64 3c 2f 62 3e 20 63 6f 6d 6d 61  ebuild</b> comma
0970: 6e 64 2d 6c 69 6e 65 20 62 65 66 6f 72 65 20 74  nd-line before t
0980: 68 65 20 61 72 74 69 66 61 63 74 20 63 6f 6e 74  he artifact cont
0990: 65 6e 74 0a 20 20 20 20 20 20 40 20 63 61 6e 20  ent.      @ can 
09a0: 70 75 6c 6c 65 64 20 69 6e 20 66 72 6f 6d 20 6f  pulled in from o
09b0: 74 68 65 72 20 72 65 73 70 6f 73 69 74 6f 72 69  ther respositori
09c0: 65 73 2e 3c 2f 66 6f 6e 74 3e 3c 2f 70 3e 0a 20  es.</font></p>. 
09d0: 20 20 20 7d 0a 20 20 7d 0a 20 20 69 66 28 20 7a     }.  }.  if( z
09e0: 55 75 69 64 20 26 26 20 50 28 22 61 64 64 22 29  Uuid && P("add")
09f0: 20 29 7b 0a 20 20 20 20 6c 6f 67 69 6e 5f 76 65   ){.    login_ve
0a00: 72 69 66 79 5f 63 73 72 66 5f 73 65 63 72 65 74  rify_csrf_secret
0a10: 28 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69  ();.    db_multi
0a20: 5f 65 78 65 63 28 22 49 4e 53 45 52 54 20 4f 52  _exec("INSERT OR
0a30: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 73 68 75   IGNORE INTO shu
0a40: 6e 20 56 41 4c 55 45 53 28 27 25 73 27 29 22 2c  n VALUES('%s')",
0a50: 20 7a 55 75 69 64 29 3b 0a 20 20 20 20 40 20 3c   zUuid);.    @ <
0a60: 70 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 62  p><font color="b
0a70: 6c 75 65 22 3e 41 72 74 69 66 61 63 74 0a 20 20  lue">Artifact.  
0a80: 20 20 40 20 3c 61 20 68 72 65 66 3d 22 25 73 28    @ <a href="%s(
0a90: 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72 74 69  g.zBaseURL)/arti
0aa0: 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29 22 3e  fact/%s(zUuid)">
0ab0: 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20 68 61  %s(zUuid)</a> ha
0ac0: 73 20 62 65 65 6e 0a 20 20 20 20 40 20 73 68 75  s been.    @ shu
0ad0: 6e 6e 65 64 2e 20 20 49 74 20 77 69 6c 6c 20 6e  nned.  It will n
0ae0: 6f 20 6c 6f 6e 67 65 72 20 62 65 20 70 75 73 68  o longer be push
0af0: 65 64 2e 0a 20 20 20 20 40 20 49 74 20 77 69 6c  ed..    @ It wil
0b00: 6c 20 62 65 20 72 65 6d 6f 76 65 64 20 66 72 6f  l be removed fro
0b10: 6d 20 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79  m the repository
0b20: 20 74 68 65 20 6e 65 78 74 20 74 69 6d 65 20 74   the next time t
0b30: 68 65 20 72 65 73 70 6f 73 69 74 6f 72 79 0a 20  he respository. 
0b40: 20 20 20 40 20 69 73 20 72 65 62 75 69 6c 74 20     @ is rebuilt 
0b50: 75 73 69 6e 67 20 74 68 65 20 3c 62 3e 66 6f 73  using the <b>fos
0b60: 73 69 6c 20 72 65 62 75 69 6c 64 3c 2f 62 3e 20  sil rebuild</b> 
0b70: 63 6f 6d 6d 61 6e 64 2d 6c 69 6e 65 3c 2f 66 6f  command-line</fo
0b80: 6e 74 3e 3c 2f 70 3e 0a 20 20 7d 0a 20 20 40 20  nt></p>.  }.  @ 
0b90: 3c 70 3e 54 68 65 20 61 72 74 69 66 61 63 74 73  <p>The artifacts
0ba0: 20 6c 69 73 74 65 64 20 62 65 6c 6f 77 20 68 61   listed below ha
0bb0: 76 65 20 62 65 65 6e 20 73 68 75 6e 6e 65 64 20  ve been shunned 
0bc0: 62 79 20 74 68 69 73 20 72 65 70 6f 73 69 74 6f  by this reposito
0bd0: 72 79 2e 0a 20 20 40 20 54 68 69 73 20 6d 65 61  ry..  @ This mea
0be0: 6e 73 20 74 68 61 74 20 74 68 65 20 61 72 74 69  ns that the arti
0bf0: 66 61 63 74 73 20 77 69 6c 6c 20 6e 6f 74 20 62  facts will not b
0c00: 65 20 74 72 61 6e 73 6d 69 74 74 65 64 20 6f 6e  e transmitted on
0c10: 20 61 20 70 75 73 68 20 6e 6f 72 0a 20 20 40 20   a push nor.  @ 
0c20: 72 65 63 69 65 76 65 64 20 6f 6e 20 61 20 70 75  recieved on a pu
0c30: 6c 6c 2e 20 20 54 68 65 73 65 20 61 72 74 69 66  ll.  These artif
0c40: 61 63 74 73 20 61 72 65 20 62 61 6e 6e 65 64 20  acts are banned 
0c50: 66 72 6f 6d 20 74 68 65 20 72 65 73 70 6f 73 69  from the resposi
0c60: 74 6f 72 79 2e 3c 2f 70 3e 0a 20 20 40 20 3c 62  tory.</p>.  @ <b
0c70: 6c 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 64 62 5f  lockquote>.  db_
0c80: 70 72 65 70 61 72 65 28 26 71 2c 20 0a 20 20 20  prepare(&q, .   
0c90: 20 20 22 53 45 4c 45 43 54 20 75 75 69 64 2c 20    "SELECT uuid, 
0ca0: 45 58 49 53 54 53 28 53 45 4c 45 43 54 20 31 20  EXISTS(SELECT 1 
0cb0: 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 20  FROM blob WHERE 
0cc0: 62 6c 6f 62 2e 75 75 69 64 3d 73 68 75 6e 2e 75  blob.uuid=shun.u
0cd0: 75 69 64 29 22 0a 20 20 20 20 20 22 20 20 46 52  uid)".     "  FR
0ce0: 4f 4d 20 73 68 75 6e 20 4f 52 44 45 52 20 42 59  OM shun ORDER BY
0cf0: 20 75 75 69 64 22 29 3b 0a 20 20 77 68 69 6c 65   uuid");.  while
0d00: 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53  ( db_step(&q)==S
0d10: 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20  QLITE_ROW ){.   
0d20: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 55 75   const char *zUu
0d30: 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74  id = db_column_t
0d40: 65 78 74 28 26 71 2c 20 30 29 3b 0a 20 20 20 20  ext(&q, 0);.    
0d50: 69 6e 74 20 73 74 69 6c 6c 45 78 69 73 74 73 20  int stillExists 
0d60: 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28  = db_column_int(
0d70: 26 71 2c 20 31 29 3b 0a 20 20 20 20 63 6e 74 2b  &q, 1);.    cnt+
0d80: 2b 3b 0a 20 20 20 20 69 66 28 20 73 74 69 6c 6c  +;.    if( still
0d90: 45 78 69 73 74 73 20 29 7b 0a 20 20 20 20 20 20  Exists ){.      
0da0: 40 20 3c 62 3e 3c 61 20 68 72 65 66 3d 22 25 73  @ <b><a href="%s
0db0: 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72 74  (g.zBaseURL)/art
0dc0: 69 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29 22  ifact/%s(zUuid)"
0dd0: 3e 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 3c 2f  >%s(zUuid)</a></
0de0: 62 3e 3c 62 72 3e 0a 20 20 20 20 7d 65 6c 73 65  b><br>.    }else
0df0: 7b 0a 20 20 20 20 20 20 40 20 3c 62 3e 25 73 28  {.      @ <b>%s(
0e00: 7a 55 75 69 64 29 3c 2f 62 3e 3c 62 72 3e 0a 20  zUuid)</b><br>. 
0e10: 20 20 20 7d 0a 20 20 7d 0a 20 20 69 66 28 20 63     }.  }.  if( c
0e20: 6e 74 3d 3d 30 20 29 7b 0a 20 20 20 20 40 20 3c  nt==0 ){.    @ <
0e30: 69 3e 6e 6f 20 61 72 74 69 66 61 63 74 73 20 61  i>no artifacts a
0e40: 72 65 20 73 68 75 6e 6e 65 64 20 6f 6e 20 74 68  re shunned on th
0e50: 69 73 20 73 65 72 76 65 72 3c 2f 69 3e 0a 20 20  is server</i>.  
0e60: 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28  }.  db_finalize(
0e70: 26 71 29 3b 0a 20 20 40 20 3c 2f 62 6c 6f 63 6b  &q);.  @ </block
0e80: 71 75 6f 74 65 3e 0a 20 20 40 20 3c 68 72 3e 0a  quote>.  @ <hr>.
0e90: 20 20 40 20 3c 61 20 6e 61 6d 65 3d 22 61 64 64    @ <a name="add
0ea0: 73 68 75 6e 22 3e 3c 2f 61 3e 0a 20 20 40 20 3c  shun"></a>.  @ <
0eb0: 70 3e 54 6f 20 73 68 75 6e 20 61 6e 20 61 72 74  p>To shun an art
0ec0: 69 66 61 63 74 2c 20 65 6e 74 65 72 20 69 74 73  ifact, enter its
0ed0: 20 55 55 49 44 20 69 6e 20 74 68 65 0a 20 20 40   UUID in the.  @
0ee0: 20 66 6f 6c 6c 6f 77 69 6e 67 20 62 6f 78 20 61   following box a
0ef0: 6e 64 20 70 72 65 73 73 20 74 68 65 20 22 53 68  nd press the "Sh
0f00: 75 6e 22 20 62 75 74 74 6f 6e 2e 20 20 54 68 69  un" button.  Thi
0f10: 73 20 77 69 6c 6c 20 63 61 75 73 65 20 74 68 65  s will cause the
0f20: 20 61 72 74 69 66 61 63 74 0a 20 20 40 20 74 6f   artifact.  @ to
0f30: 20 62 65 20 72 65 6d 6f 76 65 64 20 66 72 6f 6d   be removed from
0f40: 20 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79 20   the repository 
0f50: 61 6e 64 20 77 69 6c 6c 20 70 72 65 76 65 6e 74  and will prevent
0f60: 20 74 68 65 20 61 72 74 69 66 61 63 74 20 66 72   the artifact fr
0f70: 6f 6d 20 62 65 69 6e 67 0a 20 20 40 20 72 65 61  om being.  @ rea
0f80: 64 64 65 64 20 74 6f 20 74 68 65 20 72 65 70 6f  dded to the repo
0f90: 73 69 74 6f 72 79 20 62 79 20 73 75 62 73 65 71  sitory by subseq
0fa0: 75 65 6e 74 20 73 79 6e 63 20 6f 70 65 72 61 74  uent sync operat
0fb0: 69 6f 6e 2e 3c 2f 70 3e 0a 20 20 40 0a 20 20 40  ion.</p>.  @.  @
0fc0: 20 3c 70 3e 57 61 72 6e 69 6e 67 3a 20 20 53 68   <p>Warning:  Sh
0fd0: 75 6e 6e 69 6e 67 20 73 68 6f 75 6c 64 20 6f 6e  unning should on
0fe0: 6c 79 20 62 65 20 75 73 65 64 20 74 6f 20 72 65  ly be used to re
0ff0: 6d 6f 76 65 20 69 6e 61 70 70 72 6f 70 72 69 61  move inappropria
1000: 74 65 20 63 6f 6e 74 65 6e 74 0a 20 20 40 20 66  te content.  @ f
1010: 72 6f 6d 20 74 68 65 20 72 65 70 6f 73 69 74 6f  rom the reposito
1020: 72 79 2e 20 20 49 6e 61 70 70 72 6f 70 72 69 61  ry.  Inappropria
1030: 74 65 20 63 6f 6e 74 65 6e 74 20 69 6e 63 6c 75  te content inclu
1040: 64 65 73 20 73 75 63 68 20 74 68 69 6e 67 73 20  des such things 
1050: 61 73 0a 20 20 40 20 73 70 61 6d 20 61 64 64 65  as.  @ spam adde
1060: 64 20 74 6f 20 57 69 6b 69 2c 20 66 69 6c 65 73  d to Wiki, files
1070: 20 74 68 61 74 20 76 69 6f 6c 61 74 65 20 63 6f   that violate co
1080: 70 79 72 69 67 68 74 20 6f 72 20 70 61 74 65 6e  pyright or paten
1090: 74 20 61 67 72 65 65 6d 65 6e 74 73 2c 0a 20 20  t agreements,.  
10a0: 40 20 6f 72 20 61 72 74 69 66 61 63 74 73 20 74  @ or artifacts t
10b0: 68 61 74 20 62 79 20 64 65 73 69 67 6e 20 6f 72  hat by design or
10c0: 20 61 63 63 69 64 65 6e 74 20 69 6e 74 65 72 66   accident interf
10d0: 65 72 65 20 77 69 74 68 20 74 68 65 20 70 72 6f  ere with the pro
10e0: 63 65 73 73 69 6e 67 0a 20 20 40 20 6f 66 20 74  cessing.  @ of t
10f0: 68 65 20 72 65 70 6f 73 69 74 6f 72 79 2e 20 20  he repository.  
1100: 44 6f 20 6e 6f 74 20 73 68 75 6e 20 61 72 74 69  Do not shun arti
1110: 66 61 63 74 73 20 6d 65 72 65 6c 79 20 74 6f 20  facts merely to 
1120: 72 65 6d 6f 76 65 20 74 68 65 6d 20 66 72 6f 6d  remove them from
1130: 0a 20 20 40 20 73 69 67 68 74 20 2d 20 73 65 74  .  @ sight - set
1140: 20 74 68 65 20 22 68 69 64 64 65 6e 22 20 74 61   the "hidden" ta
1150: 67 20 6f 6e 20 73 75 63 68 20 61 72 74 69 66 61  g on such artifa
1160: 63 74 73 20 69 6e 73 74 65 61 64 2e 3c 2f 70 3e  cts instead.</p>
1170: 0a 20 20 40 20 0a 20 20 40 20 3c 62 6c 6f 63 6b  .  @ .  @ <block
1180: 71 75 6f 74 65 3e 0a 20 20 40 20 3c 66 6f 72 6d  quote>.  @ <form
1190: 20 6d 65 74 68 6f 64 3d 22 50 4f 53 54 22 20 61   method="POST" a
11a0: 63 74 69 6f 6e 3d 22 25 73 28 67 2e 7a 42 61 73  ction="%s(g.zBas
11b0: 65 55 52 4c 29 2f 25 73 28 67 2e 7a 50 61 74 68  eURL)/%s(g.zPath
11c0: 29 22 3e 0a 20 20 6c 6f 67 69 6e 5f 69 6e 73 65  )">.  login_inse
11d0: 72 74 5f 63 73 72 66 5f 73 65 63 72 65 74 28 29  rt_csrf_secret()
11e0: 3b 0a 20 20 40 20 3c 69 6e 70 75 74 20 74 79 70  ;.  @ <input typ
11f0: 65 3d 22 74 65 78 74 22 20 6e 61 6d 65 3d 22 75  e="text" name="u
1200: 75 69 64 22 20 76 61 6c 75 65 3d 22 25 68 28 50  uid" value="%h(P
1210: 44 28 22 73 68 75 6e 22 2c 22 22 29 29 22 20 73  D("shun",""))" s
1220: 69 7a 65 3d 22 35 30 22 3e 0a 20 20 40 20 3c 69  ize="50">.  @ <i
1230: 6e 70 75 74 20 74 79 70 65 3d 22 73 75 62 6d 69  nput type="submi
1240: 74 22 20 6e 61 6d 65 3d 22 61 64 64 22 20 76 61  t" name="add" va
1250: 6c 75 65 3d 22 53 68 75 6e 22 3e 0a 20 20 40 20  lue="Shun">.  @ 
1260: 3c 2f 66 6f 72 6d 3e 0a 20 20 40 20 3c 2f 62 6c  </form>.  @ </bl
1270: 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 40 0a 20 20  ockquote>.  @.  
1280: 40 20 3c 70 3e 45 6e 74 65 72 20 74 68 65 20 55  @ <p>Enter the U
1290: 55 49 44 20 6f 66 20 61 20 70 72 65 76 69 6f 75  UID of a previou
12a0: 73 20 73 68 75 6e 6e 65 64 20 61 72 74 69 66 61  s shunned artifa
12b0: 63 74 20 74 6f 20 63 61 75 73 65 20 69 74 20 74  ct to cause it t
12c0: 6f 20 62 65 0a 20 20 40 20 61 63 63 65 70 74 65  o be.  @ accepte
12d0: 64 20 61 67 61 69 6e 20 69 6e 20 74 68 65 20 72  d again in the r
12e0: 65 70 6f 73 69 74 6f 72 79 2e 20 20 54 68 65 20  epository.  The 
12f0: 61 72 74 69 66 61 63 74 20 63 6f 6e 74 65 6e 74  artifact content
1300: 20 69 73 20 6e 6f 74 0a 20 20 40 20 72 65 73 74   is not.  @ rest
1310: 6f 72 65 64 20 62 65 63 61 75 73 65 20 74 68 65  ored because the
1320: 20 63 6f 6e 74 65 6e 74 20 69 73 20 75 6e 6b 6e   content is unkn
1330: 6f 77 6e 2e 20 20 54 68 65 20 6f 6e 6c 79 20 63  own.  The only c
1340: 68 61 6e 67 65 20 69 73 20 74 68 61 74 0a 20 20  hange is that.  
1350: 40 20 74 68 65 20 66 6f 72 6d 65 72 6c 79 20 73  @ the formerly s
1360: 68 75 6e 6e 65 64 20 61 72 74 69 66 61 63 74 20  hunned artifact 
1370: 77 69 6c 6c 20 62 65 20 61 63 63 65 70 74 65 64  will be accepted
1380: 20 6f 6e 20 73 75 62 73 65 71 75 65 6e 74 20 73   on subsequent s
1390: 79 6e 63 0a 20 20 40 20 6f 70 65 72 61 74 69 6f  ync.  @ operatio
13a0: 6e 73 2e 3c 2f 70 3e 0a 20 20 40 0a 20 20 40 20  ns.</p>.  @.  @ 
13b0: 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 40  <blockquote>.  @
13c0: 20 3c 66 6f 72 6d 20 6d 65 74 68 6f 64 3d 22 50   <form method="P
13d0: 4f 53 54 22 20 61 63 74 69 6f 6e 3d 22 25 73 28  OST" action="%s(
13e0: 67 2e 7a 42 61 73 65 55 52 4c 29 2f 25 73 28 67  g.zBaseURL)/%s(g
13f0: 2e 7a 50 61 74 68 29 22 3e 0a 20 20 6c 6f 67 69  .zPath)">.  logi
1400: 6e 5f 69 6e 73 65 72 74 5f 63 73 72 66 5f 73 65  n_insert_csrf_se
1410: 63 72 65 74 28 29 3b 0a 20 20 40 20 3c 69 6e 70  cret();.  @ <inp
1420: 75 74 20 74 79 70 65 3d 22 74 65 78 74 22 20 6e  ut type="text" n
1430: 61 6d 65 3d 22 75 75 69 64 22 20 73 69 7a 65 3d  ame="uuid" size=
1440: 22 35 30 22 3e 0a 20 20 40 20 3c 69 6e 70 75 74  "50">.  @ <input
1450: 20 74 79 70 65 3d 22 73 75 62 6d 69 74 22 20 6e   type="submit" n
1460: 61 6d 65 3d 22 73 75 62 22 20 76 61 6c 75 65 3d  ame="sub" value=
1470: 22 41 63 63 65 70 74 22 3e 0a 20 20 40 20 3c 2f  "Accept">.  @ </
1480: 66 6f 72 6d 3e 0a 20 20 40 20 3c 2f 62 6c 6f 63  form>.  @ </bloc
1490: 6b 71 75 6f 74 65 3e 0a 20 20 73 74 79 6c 65 5f  kquote>.  style_
14a0: 66 6f 6f 74 65 72 28 29 3b 0a 7d 0a 0a 2f 2a 0a  footer();.}../*.
14b0: 2a 2a 20 52 65 6d 6f 76 65 20 66 72 6f 6d 20 74  ** Remove from t
14c0: 68 65 20 42 4c 4f 42 20 74 61 62 6c 65 20 61 6c  he BLOB table al
14d0: 6c 20 61 72 74 69 66 61 63 74 73 20 74 68 61 74  l artifacts that
14e0: 20 61 72 65 20 69 6e 20 74 68 65 20 53 48 55 4e   are in the SHUN
14f0: 20 74 61 62 6c 65 2e 0a 2a 2f 0a 76 6f 69 64 20   table..*/.void 
1500: 73 68 75 6e 5f 61 72 74 69 66 61 63 74 73 28 76  shun_artifacts(v
1510: 6f 69 64 29 7b 0a 20 20 53 74 6d 74 20 71 3b 0a  oid){.  Stmt q;.
1520: 20 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28    db_multi_exec(
1530: 0a 20 20 20 20 20 22 43 52 45 41 54 45 20 54 45  .     "CREATE TE
1540: 4d 50 20 54 41 42 4c 45 20 74 6f 73 68 75 6e 28  MP TABLE toshun(
1550: 72 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d  rid INTEGER PRIM
1560: 41 52 59 20 4b 45 59 29 3b 22 0a 20 20 20 20 20  ARY KEY);".     
1570: 22 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 6f 73  "INSERT INTO tos
1580: 68 75 6e 20 53 45 4c 45 43 54 20 72 69 64 20 46  hun SELECT rid F
1590: 52 4f 4d 20 62 6c 6f 62 2c 20 73 68 75 6e 20 57  ROM blob, shun W
15a0: 48 45 52 45 20 62 6c 6f 62 2e 75 75 69 64 3d 73  HERE blob.uuid=s
15b0: 68 75 6e 2e 75 75 69 64 3b 22 0a 20 20 29 3b 0a  hun.uuid;".  );.
15c0: 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c    db_prepare(&q,
15d0: 0a 20 20 20 20 20 22 53 45 4c 45 43 54 20 72 69  .     "SELECT ri
15e0: 64 20 46 52 4f 4d 20 64 65 6c 74 61 20 57 48 45  d FROM delta WHE
15f0: 52 45 20 73 72 63 69 64 20 49 4e 20 74 6f 73 68  RE srcid IN tosh
1600: 75 6e 22 0a 20 20 29 3b 0a 20 20 77 68 69 6c 65  un".  );.  while
1610: 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53  ( db_step(&q)==S
1620: 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20  QLITE_ROW ){.   
1630: 20 69 6e 74 20 73 72 63 69 64 20 3d 20 64 62 5f   int srcid = db_
1640: 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 30  column_int(&q, 0
1650: 29 3b 0a 20 20 20 20 63 6f 6e 74 65 6e 74 5f 75  );.    content_u
1660: 6e 64 65 6c 74 61 28 73 72 63 69 64 29 3b 0a 20  ndelta(srcid);. 
1670: 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65   }.  db_finalize
1680: 28 26 71 29 3b 0a 20 20 64 62 5f 6d 75 6c 74 69  (&q);.  db_multi
1690: 5f 65 78 65 63 28 0a 20 20 20 20 20 22 44 45 4c  _exec(.     "DEL
16a0: 45 54 45 20 46 52 4f 4d 20 64 65 6c 74 61 20 57  ETE FROM delta W
16b0: 48 45 52 45 20 72 69 64 20 49 4e 20 74 6f 73 68  HERE rid IN tosh
16c0: 75 6e 3b 22 0a 20 20 20 20 20 22 44 45 4c 45 54  un;".     "DELET
16d0: 45 20 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52  E FROM blob WHER
16e0: 45 20 72 69 64 20 49 4e 20 74 6f 73 68 75 6e 3b  E rid IN toshun;
16f0: 22 0a 20 20 20 20 20 22 44 52 4f 50 20 54 41 42  ".     "DROP TAB
1700: 4c 45 20 74 6f 73 68 75 6e 3b 22 0a 20 20 29 3b  LE toshun;".  );
1710: 0a 7d 0a                                         .}.