(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestFormatJSON(t *testing.T) { |
| 17 | tests := []struct { |
| 18 | name string |
| 19 | input output.ResultData |
| 20 | want string |
| 21 | }{ |
| 22 | {name: "no error", |
| 23 | input: output.ResultData{ |
| 24 | TargetURL: "https://edoardottt.github.io/pp-test", |
| 25 | ScanURL: "https://edoardottt.github.io/pp-test?constructor.prototype.oigczu=oigczu" + |
| 26 | "&__proto__[oigczu]=oigczu&constructor[prototype][oigczu]=oigczu&__proto__.oigczu=oigczu" + |
| 27 | "&__proto__.oigczu=1|2|3&__proto__[oigczu]={\"json\":\"value\"}#__proto__[oigczu]=oigczu", |
| 28 | JSEvaluation: "oigczu", |
| 29 | ScanError: "", |
| 30 | }, |
| 31 | want: `{"TargetURL":"https://edoardottt.github.io/pp-test",` + |
| 32 | `"ScanURL":"https://edoardottt.github.io/pp-test?constructor.prototype.oigczu=oigczu&__proto__` + |
| 33 | `[oigczu]=oigczu&constructor[prototype][oigczu]=oigczu&__proto__.oigczu=oigczu&__proto__.` + |
| 34 | `oigczu=1|2|3&__proto__[oigczu]={\"json\":\"value\"}#__proto__[oigczu]=oigczu",` + |
| 35 | `"JSEvaluation":"oigczu"}`, |
| 36 | }, |
| 37 | {name: "error", |
| 38 | input: output.ResultData{ |
| 39 | TargetURL: "https://edoardottt.github.io/pp-tes", |
| 40 | ScanURL: "https://edoardottt.github.io/pp-tes?constructor.prototype.sqtiwx=sqtiwx" + |
| 41 | "&__proto__[sqtiwx]=sqtiwx&constructor[prototype][sqtiwx]=sqtiwx&__proto__.sqtiwx=sqtiwx" + |
| 42 | "&__proto__.sqtiwx=1|2|3&__proto__[sqtiwx]={\"json\":\"value\"}#__proto__[sqtiwx]=sqtiwx", |
| 43 | JSEvaluation: "", |
| 44 | ScanError: "encountered an undefined value", |
| 45 | }, |
| 46 | want: `{"TargetURL":"https://edoardottt.github.io/pp-tes",` + |
| 47 | `"ScanURL":"https://edoardottt.github.io/pp-tes?constructor.prototype.sqtiwx=sqtiwx&__proto__[sqtiwx]` + |
| 48 | `=sqtiwx&constructor[prototype][sqtiwx]=sqtiwx&__proto__.sqtiwx=sqtiwx&__proto__.` + |
| 49 | `sqtiwx=1|2|3&__proto__[sqtiwx]={\"json\":\"value\"}#__proto__[sqtiwx]=` + |
| 50 | `sqtiwx","ScanError":"encountered an undefined value"}`, |
| 51 | }, |
| 52 | {name: "exploit", |
| 53 | input: output.ResultData{ |
| 54 | TargetURL: "https://edoardottt.github.io/pp-test", |
| 55 | ScanURL: "https://edoardottt.github.io/pp-test?constructor.prototype.lfhfqn=lfhfqn" + |
| 56 | "&__proto__[lfhfqn]=lfhfqn&constructor[prototype][lfhfqn]=lfhfqn&__proto__.lfhfqn=lfhfqn" + |
| 57 | "&__proto__.lfhfqn=1|2|3&__proto__[lfhfqn]={\"json\":\"value\"}#__proto__[lfhfqn]=lfhfqn", |
| 58 | JSEvaluation: "lfhfqn", |
| 59 | Fingerprint: []string{"jQuery"}, |
| 60 | ExploitURLs: []string{"https://edoardottt.github.io/pp-test/?__proto__[url][]=data:,alert(1337)//" + |
| 61 | "&__proto__[dataType]=script", |
| 62 | "https://edoardottt.github.io/pp-test/?__proto__[context]=%3Cimg/src/onerror%3dalert(1337)" + |
| 63 | "%3E&__proto__[jquery]=x"}, |
| 64 | ScanError: "", |
| 65 | References: []string{"https://github.com/BlackFan/client-side-prototype-pollution/blob/master/gadgets/jquery.md"}, |
| 66 | }, |
| 67 | want: `{"TargetURL":"https://edoardottt.github.io/pp-test",` + |
| 68 | `"ScanURL":"https://edoardottt.github.io/pp-test?constructor.prototype.lfhfqn=lfhfqn` + |
| 69 | `&__proto__[lfhfqn]=lfhfqn&constructor[prototype][lfhfqn]=lfhfqn&__proto__.lfhfqn=lfhfqn` + |
| 70 | `&__proto__.lfhfqn=1|2|3&__proto__[lfhfqn]={\"json\":\"value\"}#__proto__[lfhfqn]=lfhfqn",` + |
| 71 | `"JSEvaluation":"lfhfqn",` + |
| 72 | `"Fingerprint":["jQuery"],` + |
| 73 | `"ExploitURLs":["https://edoardottt.github.io/pp-test/?__proto__[url][]=data:,alert(1337)//` + |
nothing calls this directly
no test coverage detected