Top Banner
KATCH: HighCoverage Tes2ng of So6ware Patches Paul Marinescu and Cris2an Cadar Imperial College London
23

KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea •...

Jun 30, 2018

Download

Documents

vuongdiep
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

KATCH:  High-­‐Coverage  Tes2ng  of  So6ware  Patches  

Paul  Marinescu  and  Cris2an  Cadar  Imperial  College  London  

Page 2: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Intro  

•  Manual  tes2ng  is  hard  

•  Supplement  it  with  automa2c  tes2ng  

•  We  focus  on  tes2ng  so6ware  changes    

2  

Page 3: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Manual  Patch  Coverage  

0%  

10%  

20%  

30%  

40%  

50%  

60%  

70%  

80%  

90%  

100%  

findu2ls   diffu2ls   binu2ls  

Covered  by  test  suite   Not  covered  

3  

Page 4: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

4  

Page 5: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Example:  Tes2ng  diffu2ls  $ ls diffutils config.sh build.sh regression-test.sh

$ cat config.sh

REPO="git://git.savannah.gnu.org/diffutils.git"

DIFFTARGETS="src lib"

PROGRAMS="src/diff src/diff3 src/sdiff src/cmp"

LIBS="-lrt"

$ katch diffutils 0 100

5  

Page 6: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

High-­‐Level  Idea  

•  Synthesize  inputs  which  execute  the  patch  code  

•  Given  a  program  loca2on  (e.g.  file  name,  line  number),  synthesize  an  input  which  executes  that  loca2on  

6  

Page 7: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

High-­‐Level  Approach  

•  Concrete/Symbolic  execu2on  mix  +  heuris2cs  

•  Seeded  with  exis2ng  inputs  from  the  regression  test  suites  

7  

Page 8: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

System  Overview  

8  

Patch  Preprocessing  

Input  Selec4on  

Symbolic  Execu4on  Greedy  

Explora2on  Defini2on  Switching  

Informed  Path  Regenera2on  

Program,  Patch,  

Test  suite  

New  program  inputs  

KATCH  

Page 9: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Patch  Preprocessing  Index: src/mod_accesslog.c ========================================== --- src/mod_accesslog.c (revision 2659) +++ src/mod_accesslog.c (revision 2660) @@ -156,6 +156,13 @@

void log(char input) { int file = open(”access.log”, ...); + if (input >= ’␣’ && + input <= ’~’) { // printable characters write(file, &input, 1); + } else { + char escinput; + escinput = escape(input); + write(file, &escinput, 1); + } close(file); }

TARGET  1  src/mod_accesslog.c:164

9  

Page 10: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Input  Selec2on  

•  Rank  exis2ng  inputs  based  on  how  ‘easy’  it  is  to  change  them  to  execute  the  patch  

•  Op2miza2on  

•  Lightweight  

10  

Page 11: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Input  Selec2on  Input  A   Input  B  

Example  control-­‐flow  graph  

–  distance  4   –  distance  2  

11  

Page 12: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Concrete/Symbolic  Execu2on  

•  Itera2ve  refinement  of  the  ini2al  input  

•  Get  ‘closer’  to  the  target  at  each  itera2on  

•  Symbolic  execu2on  +  path  selec2on  heuris2cs  

12  

Page 13: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

lighfpd  r2660:  patch  modifies  log()  to  escape  sensi2ve  characters  

Greedy  Explora2on  Step  

void log(char input) { int file = open(”access.log”, …); if (input >= ’␣’ && input <= ’~’) { // printable characters write(file, &input, 1); + } else { + char escinput = escape(input); + write(file, &escinput, 1); + } close(file); }

13  

Page 14: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Available  input:  “t”  (or  any  printable  char)  

1.  Greedy  step:  choose  the  symbolic  branch  whose  unexplored  side  is  closest  to  the  patch.  

2.  Explore  this  side!    

Greedy  Explora2on  Step  

void log(char input) { int file = open(”access.log”, …); if (input >= ’␣’ && input <= ’~’) { // printable characters write(file, &input, 1); + } else { + char escinput = escape(input); + write(file, &escinput, 1); + } close(file); }

14  

Page 15: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

void log(char input) { if (input >= ’␣’ && input <= ’~’) { . . . } else { + . . . } } if (0 == strcmp(request, “GET”) . . . for (char* p = request; *p; p++) log(*p);

Available  input:  “GET”  

1.  Backtrack  to  the  symbolic  branch  that  disallows  this  side  to  be  executed  

2.  Explore  the  other  side  of  that  branch  

 

Informed  Path  Regenera2on  

Greedy  step  fails!  

request[2]  ≠  ‘T’  15  

Page 16: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

enum escape_t escape; void log(char input) { if (escape == ESCAPE_ALL) { + . . . } } opt = getopt_long(argc, argv, ...); switch (opt) { case ‘a’: escape = ESCAPE_SPACE; break; case ‘b’: escape = ESCAPE_ALL; . . . log(. . .);

Available  test:  opt  =  ‘a’  

1.  Find  all  reaching  defini2ons  for  the  variables  involved  and  try  to  cover  another  one  

2.  Favors  defini2ons  that  can  be  sta2cally  shown  to  sa2sfy  target,  or  unexecuted  defini2ons  

Defini2on  Switching  

Backtracking  step  fails!  

Patch  guarded  by  concrete  branch  

16  

Page 17: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Evalua2on  

0  

20  

40  

60  

80  

100  

120  

Adde

d/mod

ified

 executable  ba

sic  blocks  

findu2ls   diffu2ls   binu2ls  

2010   2011   2012   2013  

114  executable  patches  1362  targets  

17  

Page 18: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Coverage  Improvement  

0%  

10%  

20%  

30%  

40%  

50%  

60%  

70%  

80%  

90%  

100%  

findu2ls   diffu2ls   binu2ls  

Covered  by  test  suite   Covered  by  KATCH   Not  covered  

18  

Page 19: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Bugs  Found  

15  Crash  Bugs  6  bugs  in  patch  code   5  bugs  close  to  patch  code  4  bugs  

unknown  causal  rela2on  

19  

Page 20: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Bugs  Found  

12  2   1  

Already  fixed  in  the  last  version  

Reported  and  fixed  

Reported  and  pending  

20  

Page 21: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Automa2c  Patch  Tes2ng  

Prac2cal  autonomous  tes2ng  system    

Coverage  improvement  and  bug  finding    

Short  ar2fact*  presenta2on  on  Friday  hfp://srg.doc.ic.ac.uk/projects/katch/  

*Successfully  evaluated  by  the  ESEC/FSE  ar2fact  evalua2on  commifee  21  

Page 22: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Selected  Related  Work  

•  Directed  Test  Suite  Augmenta2on  (APSEC’09,  FSE’10)  

•  Directed  Symbolic  Execu2on  (SAS’11)  

•  Differen2al  Symbolic  Execu2on  (FSE’08)  

•  Directed  Incremental  Sym  bolic  Execu2on  (PLDI’11)  

22  

Page 23: KATCH:’High+Coverage’Tes2ng’of’ So6ware’Patches’srg.doc.ic.ac.uk/files/slides/katch-esecfse-13.pdf · $ katch diffutils 0 100 5. High+Level’Idea • Synthesize’inputs’which’execute’the’patch

Heuris2c  Contribu2on  

Suite   Greedy   Greedy+IPR   Greedy+DS   KATCH  

findu2ls   74   85   78   85  

diffu2ls   25   29   49   63  

binu2ls   70   121   76   135  

Total   169   235   203   283  

IPR  =  Informed  Path  Regenera2on  DS    =  Defini2on  Switching  

23