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AgICAgICAgICAgICAgICAiZm9yIGFueSBuZWNlc3NhcnkgbWFya3VwIG1hc3NhZ2UuIikKKworICAgICAgICBpZiAnc21hcnRRdW90ZXNUbycgaW4ga3dhcmdzOgorICAgICAgICAgICAgZGVsIGt3YXJnc1snc21hcnRRdW90ZXNUbyddCisgICAgICAgICAgICB3YXJuaW5ncy53YXJuKAorICAgICAgICAgICAgICAgICJCUzQgZG9lcyBub3QgcmVzcGVjdCB0aGUgc21hcnRRdW90ZXNUbyBhcmd1bWVudCB0byB0aGUgIgorICAgICAgICAgICAgICAgICJCZWF1dGlmdWxTb3VwIGNvbnN0cnVjdG9yLiBTbWFydCBxdW90ZXMgYXJlIGFsd2F5cyBjb252ZXJ0ZWQgIgorICAgICAgICAgICAgICAgICJ0byBVbmljb2RlIGNoYXJhY3RlcnMuIikKKworICAgICAgICBpZiAnc2VsZkNsb3NpbmdUYWdzJyBpbiBrd2FyZ3M6CisgICAgICAgICAgICBkZWwga3dhcmdzWydzZWxmQ2xvc2luZ1RhZ3MnXQorICAgICAgICAgICAgd2FybmluZ3Mud2FybigKKyAgICAgICAgICAgICAgICAiQlM0IGRvZXMgbm90IHJlc3BlY3QgdGhlIHNlbGZDbG9zaW5nVGFncyBhcmd1bWVudCB0byB0aGUgIgorICAgICAgICAgICAgICAgICJCZWF1dGlmdWxTb3VwIGNvbnN0cnVjdG9yLiBUaGUgdHJlZSBidWlsZGVyIGlzIHJlc3BvbnNpYmxlICIKKyAgICAgICAgICAgICAgICAiZm9yIHVuZGVyc3RhbmRpbmcgc2VsZi1jbG9zaW5nIHRhZ3MuIikKKworICAgICAgICBpZiAnaXNIVE1MJyBpbiBrd2FyZ3M6CisgICAgICAgICAgICBkZWwga3dhcmdzWydpc0hUTUwnXQorICAgICAgICAgICAgd2FybmluZ3Mud2FybigKKyAgICAgICAgICAgICAgICAiQlM0IGRvZXMgbm90IHJlc3BlY3QgdGhlIGlzSFRNTCBhcmd1bWVudCB0byB0aGUgIgorICAgICAgICAgICAgICAgICJCZWF1dGlmdWxTb3VwIGNvbnN0cnVjdG9yLiBZb3UgY2FuIHBhc3MgaW4gZmVhdHVyZXM9J2h0bWwnICIKKyAgICAgICAgICAgICAgICAib3IgZmVhdHVyZXM9J3htbCcgdG8gZ2V0IGEgYnVpbGRlciBjYXBhYmxlIG9mIGhhbmRsaW5nICIKKyAgICAgICAgICAgICAgICAib25lIG9yIHRoZSBvdGhlci4iKQorCisgICAgICAgIGRlZiBkZXByZWNhdGVkX2FyZ3VtZW50KG9sZF9uYW1lLCBuZXdfbmFtZSk6CisgICAgICAgICAgICBpZiBvbGRfbmFtZSBpbiBrd2FyZ3M6CisgICAgICAgICAgICAgICAgd2FybmluZ3Mud2FybigKKyAgICAgICAgICAgICAgICAgICAgJ1RoZSAiJXMiIGFyZ3VtZW50IHRvIHRoZSBCZWF1dGlmdWxTb3VwIGNvbnN0cnVjdG9yICcKKyAgICAgICAgICAgICAgICAgICAgJ2hhcyBiZWVuIHJlbmFtZWQgdG8gIiVzLiInICUgKG9sZF9uYW1lLCBuZXdfbmFtZSkpCisgICAgICAgICAgICAgICAgdmFsdWUgPSBrd2FyZ3Nbb2xkX25hbWVdCisgICAgICAgICAgICAgICAgZGVsIGt3YXJnc1tvbGRfbmFtZV0KKyAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWUKKyAgICAgICAgICAgIHJldHVybiBOb25lCisKKyAgICAgICAgcGFyc2Vfb25seSA9IHBhcnNlX29ubHkgb3IgZGVwcmVjYXRlZF9hcmd1bWVudCgKKyAgICAgICAgICAgICJwYXJzZU9ubHlUaGVzZSIsICJwYXJzZV9vbmx5IikKKworICAgICAgICBmcm9tX2VuY29kaW5nID0gZnJvbV9lbmNvZGluZyBvciBkZXByZWNhdGVkX2FyZ3VtZW50KAorICAgICAgICAgICAgImZyb21FbmNvZGluZyIsICJmcm9tX2VuY29kaW5nIikKKworICAgICAgICBpZiBsZW4oa3dhcmdzKSA+IDA6CisgICAgICAgICAgICBhcmcgPSBrd2FyZ3Mua2V5cygpLnBvcCgpCisgICAgICAgICAgICByYWlzZSBUeXBlRXJyb3IoCisgICAgICAgICAgICAgICAgIl9faW5pdF9fKCkgZ290IGFuIHVuZXhwZWN0ZWQga2V5d29yZCBhcmd1bWVudCAnJXMnIiAlIGFyZykKKworICAgICAgICBpZiBidWlsZGVyIGlzIE5vbmU6CisgICAgICAgICAgICBpZiBpc2luc3RhbmNlKGZlYXR1cmVzLCBiYXNlc3RyaW5nKToKKyAgICAgICAgICAgICAgICBmZWF0dXJlcyA9IFtmZWF0dXJlc10KKyAgICAgICAgICAgIGlmIGZlYXR1cmVzIGlzIE5vbmUgb3IgbGVuKGZlYXR1cmVzKSA9PSAwOgorICAgICAgICAgICAgICAgIGZlYXR1cmVzID0gc2VsZi5ERUZBVUxUX0JVSUxERVJfRkVBVFVSRVMKKyAgICAgICAgICAgIGJ1aWxkZXJfY2xhc3MgPSBidWlsZGVyX3JlZ2lzdHJ5Lmxvb2t1cCgqZmVhdHVyZXMpCisgICAgICAgICAgICBpZiBidWlsZGVyX2NsYXNzIGlzIE5vbmU6CisgICAgICAgICAgICAgICAgcmFpc2UgRmVhdHVyZU5vdEZvdW5kKAorICAgICAgICAgICAgICAgICAgICAiQ291bGRuJ3QgZmluZCBhIHRyZWUgYnVpbGRlciB3aXRoIHRoZSBmZWF0dXJlcyB5b3UgIgorICAgICAgICAgICAgICAgICAgICAicmVxdWVzdGVkOiAlcy4gRG8geW91IG5lZWQgdG8gaW5zdGFsbCBhIHBhcnNlciBsaWJyYXJ5PyIKKyAgICAgICAgICAgICAgICAgICAgJSAiLCIuam9pbihmZWF0dXJlcykpCisgICAgICAgICAgICBidWlsZGVyID0gYnVpbGRlcl9jbGFzcygpCisgICAgICAgIHNlbGYuYnVpbGRlciA9IGJ1aWxkZXIKKyAgICAgICAgc2VsZi5pc194bWwgPSBidWlsZGVyLmlzX3htbAorICAgICAgICBzZWxmLmJ1aWxkZXIuc291cCA9IHNlbGYKKworICAgICAgICBzZWxmLnBhcnNlX29ubHkgPSBwYXJzZV9vbmx5CisKKyAgICAgICAgaWYgaGFzYXR0cihtYXJrdXAsICdyZWFkJyk6ICAgICAgICAjIEl0J3MgYSBmaWxlLXR5cGUgb2JqZWN0LgorICAgICAgICAgICAgbWFya3VwID0gbWFya3VwLnJlYWQoKQorICAgICAgICBlbGlmIGxlbihtYXJrdXApIDw9IDI1NjoKKyAgICAgICAgICAgICMgUHJpbnQgb3V0IHdhcm5pbmdzIGZvciBhIGNvdXBsZSBiZWdpbm5lciBwcm9ibGVtcworICAgICAgICAgICAgIyBpbnZvbHZpbmcgcGFzc2luZyBub24tbWFya3VwIHRvIEJlYXV0aWZ1bCBTb3VwLgorICAgICAgICAgICAgIyBCZWF1dGlmdWwgU291cCB3aWxsIHN0aWxsIHBhcnNlIHRoZSBpbnB1dCBhcyBtYXJrdXAsCisgICAgICAgICAgICAjIGp1c3QgaW4gY2FzZSB0aGF0J3Mgd2hhdCB0aGUgdXNlciByZWFsbHkgd2FudHMuCisgICAgICAgICAgICBpZiAoaXNpbnN0YW5jZShtYXJrdXAsIHVuaWNvZGUpCisgICAgICAgICAgICAgICAgYW5kIG5vdCBvcy5wYXRoLnN1cHBvcnRzX3VuaWNvZGVfZmlsZW5hbWVzKToKKyAgICAgICAgICAgICAgICBwb3NzaWJsZV9maWxlbmFtZSA9IG1hcmt1cC5lbmNvZGUoInV0ZjgiKQorICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICBwb3NzaWJsZV9maWxlbmFtZSA9IG1hcmt1cAorICAgICAgICAgICAgaXNfZmlsZSA9IEZhbHNlCisgICAgICAgICAgICB0cnk6CisgICAgICAgICAgICAgICAgaXNfZmlsZSA9IG9zLnBhdGguZXhpc3RzKHBvc3NpYmxlX2ZpbGVuYW1lKQorICAgICAgICAgICAgZXhjZXB0IEV4Y2VwdGlvbiwgZToKKyAgICAgICAgICAgICAgICAjIFRoaXMgaXMgYWxtb3N0IGNlcnRhaW5seSBhIHByb2JsZW0gaW52b2x2aW5nCisgICAgICAgICAgICAgICAgIyBjaGFyYWN0ZXJzIG5vdCB2YWxpZCBpbiBmaWxlbmFtZXMgb24gdGhpcworICAgICAgICAgICAgICAgICMgc3lzdGVtLiBKdXN0IGxldCBpdCBnby4KKyAgICAgICAgICAgICAgICBwYXNzCisgICAgICAgICAgICBpZiBpc19maWxlOgorICAgICAgICAgICAgICAgIHdhcm5pbmdzLndhcm4oCisgICAgICAgICAgICAgICAgICAgICciJXMiIGxvb2tzIGxpa2UgYSBmaWxlbmFtZSwgbm90IG1hcmt1cC4gWW91IHNob3VsZCBwcm9iYWJseSBvcGVuIHRoaXMgZmlsZSBhbmQgcGFzcyB0aGUgZmlsZWhhbmRsZSBpbnRvIEJlYXV0aWZ1bCBTb3VwLicgJSBtYXJrdXApCisgICAgICAgICAgICBpZiBtYXJrdXBbOjVdID09ICJodHRwOiIgb3IgbWFya3VwWzo2XSA9PSAiaHR0cHM6IjoKKyAgICAgICAgICAgICAgICAjIFRPRE86IFRoaXMgaXMgdWdseSBidXQgSSBjb3VsZG4ndCBnZXQgaXQgdG8gd29yayBpbgorICAgICAgICAgICAgICAgICMgUHl0aG9uIDMgb3RoZXJ3aXNlLgorICAgICAgICAgICAgICAgIGlmICgoaXNpbnN0YW5jZShtYXJrdXAsIGJ5dGVzKSBhbmQgbm90IGInICcgaW4gbWFya3VwKQorICAgICAgICAgICAgICAgICAgICBvciAoaXNpbnN0YW5jZShtYXJrdXAsIHVuaWNvZGUpIGFuZCBub3QgdScgJyBpbiBtYXJrdXApKToKKyAgICAgICAgICAgICAgICAgICAgd2FybmluZ3Mud2FybigKKyAgICAgICAgICAgICAgICAgICAgICAgICciJXMiIGxvb2tzIGxpa2UgYSBVUkwuIEJlYXV0aWZ1bCBTb3VwIGlzIG5vdCBhbiBIVFRQIGNsaWVudC4gWW91IHNob3VsZCBwcm9iYWJseSB1c2UgYW4gSFRUUCBjbGllbnQgdG8gZ2V0IHRoZSBkb2N1bWVudCBiZWhpbmQgdGhlIFVSTCwgYW5kIGZlZWQgdGhhdCBkb2N1bWVudCB0byBCZWF1dGlmdWwgU291cC4nICUgbWFya3VwKQorCisgICAgICAgIGZvciAoc2VsZi5tYXJrdXAsIHNlbGYub3JpZ2luYWxfZW5jb2RpbmcsIHNlbGYuZGVjbGFyZWRfaHRtbF9lbmNvZGluZywKKyAgICAgICAgIHNlbGYuY29udGFpbnNfcmVwbGFjZW1lbnRfY2hhcmFjdGVycykgaW4gKAorICAgICAgICAgICAgc2VsZi5idWlsZGVyLnByZXBhcmVfbWFya3VwKG1hcmt1cCwgZnJvbV9lbmNvZGluZykpOgorICAgICAgICAgICAgc2VsZi5yZXNldCgpCisgICAgICAgICAgICB0cnk6CisgICAgICAgICAgICAgICAgc2VsZi5fZmVlZCgpCisgICAgICAgICAgICAgICAgYnJlYWsKKyAgICAgICAgICAgIGV4Y2VwdCBQYXJzZXJSZWplY3RlZE1hcmt1cDoKKyAgICAgICAgICAgICAgICBwYXNzCisKKyAgICAgICAgIyBDbGVhciBvdXQgdGhlIG1hcmt1cCBhbmQgcmVtb3ZlIHRoZSBidWlsZGVyJ3MgY2lyY3VsYXIKKyAgICAgICAgIyByZWZlcmVuY2UgdG8gdGhpcyBvYmplY3QuCisgICAgICAgIHNlbGYubWFya3VwID0gTm9uZQorICAgICAgICBzZWxmLmJ1aWxkZXIuc291cCA9IE5vbmUKKworICAgIGRlZiBfZmVlZChzZWxmKToKKyAgICAgICAgIyBDb252ZXJ0IHRoZSBkb2N1bWVudCB0byBVbmljb2RlLgorICAgICAgICBzZWxmLmJ1aWxkZXIucmVzZXQoKQorCisgICAgICAgIHNlbGYuYnVpbGRlci5mZWVkKHNlbGYubWFya3VwKQorICAgICAgICAjIENsb3NlIG91dCBhbnkgdW5maW5pc2hlZCBzdHJpbmdzIGFuZCBjbG9zZSBhbGwgdGhlIG9wZW4gdGFncy4KKyAgICAgICAgc2VsZi5lbmREYXRhKCkKKyAgICAgICAgd2hpbGUgc2VsZi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bGYuYnVpbGRlci5wcmVzZXJ2ZV93aGl0ZXNwYWNlX3RhZ3M6CisgICAgICAgICAgICBzZWxmLnByZXNlcnZlX3doaXRlc3BhY2VfdGFnX3N0YWNrLmFwcGVuZCh0YWcpCisKKyAgICBkZWYgZW5kRGF0YShzZWxmLCBjb250YWluZXJDbGFzcz1OYXZpZ2FibGVTdHJpbmcpOgorICAgICAgICBpZiBzZWxmLmN1cnJlbnRfZGF0YToKKyAgICAgICAgICAgIGN1cnJlbnRfZGF0YSA9IHUnJy5qb2luKHNlbGYuY3VycmVudF9kYXRhKQorICAgICAgICAgICAgIyBJZiB3aGl0ZXNwYWNlIGlzIG5vdCBwcmVzZXJ2ZWQsIGFuZCB0aGlzIHN0cmluZyBjb250YWlucworICAgICAgICAgICAgIyBub3RoaW5nIGJ1dCBBU0NJSSBzcGFjZXMsIHJlcGxhY2UgaXQgd2l0aCBhIHNpbmdsZSBzcGFjZQorICAgICAgICAgICAgIyBvciBuZXdsaW5lLgorICAgICAgICAgICAgaWYgbm90IHNlbGYucHJlc2VydmVfd2hpdGVzcGFjZV90YWdfc3RhY2s6CisgICAgICAgICAgICAgICAgc3RyaXBwYWJsZSA9IFRydWUKKyAgICAgICAgICAgICAgICBmb3IgaSBpbiBjdXJyZW50X2RhdGE6CisgICAgICAgICAgICAgICAgICAgIGlmIGkgbm90IGluIHNlbGYuQVNDSUlfU1BBQ0VTOgorICAgICAgICAgICAgICAgICAgICAgICAgc3RyaXBwYWJsZSA9IEZhbHNlCisgICAgICAgICAgICAgICAgICAgICAgICBicmVhaworICAgICAgICAgICAgICAgIGlmIHN0cmlwcGFibGU6CisgICAgICAgICAgICAgICAgICAgIGlmICdcbicgaW4gY3VycmVudF9kYXRhOgorICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudF9kYXRhID0gJ1xuJworICAgICAgICAgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudF9kYXRhID0gJyAnCisKKyAgICAgICAgICAgICMgUmVzZXQgdGhlIGRhdGEgY29sbGVjdG9yLgorICAgICAgICAgICAgc2VsZi5jdXJyZW50X2RhdGEgPSBbXQorCisgICAgICAgICAgICAjIFNob3VsZCB3ZSBhZGQgdGhpcyBzdHJpbmcgdG8gdGhlIHRyZWUgYXQgYWxsPworICAgICAgICAgICAgaWYgc2VsZi5wYXJzZV9vbmx5IGFuZCBsZW4oc2VsZi50YWdTdGFjaykgPD0gMSBhbmQgXAorICAgICAgICAgICAgICAgICAgIChub3Qgc2VsZi5wYXJzZV9vbmx5LnRleHQgb3IgXAorICAgICAgICAgICAgICAgICAgICBub3Qgc2VsZi5wYXJzZV9vbmx5LnNlYXJjaChjdXJyZW50X2RhdGEpKToKKyAgICAgICAgICAgICAgICByZXR1cm4KKworICAgICAgICAgICAgbyA9IGNvbnRhaW5lckNsYXNzKGN1cnJlbnRfZGF0YSkKKyAgICAgICAgICAgIHNlbGYub2JqZWN0X3dhc19wYXJzZWQobykKKworICAgIGRlZiBvYmplY3Rfd2FzX3BhcnNlZChzZWxmLCBvLCBwYXJlbnQ9Tm9uZSwgbW9zdF9yZWNlbnRfZWxlbWVudD1Ob25lKToKKyAgICAgICAgIiIiQWRkIGFuIG9iamVjdCB0byB0aGUgcGFyc2UgdHJlZS4iIiIKKyAgICAgICAgcGFyZW50ID0gcGFyZW50IG9yIHNlbGYuY3VycmVudFRhZworICAgICAgICBtb3N0X3JlY2VudF9lbGVtZW50ID0gbW9zdF9yZWNlbnRfZWxlbWVudCBvciBzZWxmLl9tb3N0X3JlY2VudF9lbGVtZW50CisgICAgICAgIG8uc2V0dXAocGFyZW50LCBtb3N0X3JlY2VudF9lbGVtZW50KQorCisgICAgICAgIGlmIG1vc3RfcmVjZW50X2VsZW1lbnQgaXMgbm90IE5vbmU6CisgICAgICAgICAgICBtb3N0X3JlY2VudF9lbGVtZW50Lm5leHRfZWxlbWVudCA9IG8KKyAgICAgICAgc2VsZi5fbW9zdF9yZWNlbnRfZWxlbWVudCA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gICAgICAgICAgICAgIGJyZWFrCisgICAgICAgICAgICBtb3N0X3JlY2VudGx5X3BvcHBlZCA9IHNlbGYucG9wVGFnKCkKKworICAgICAgICByZXR1cm4gbW9zdF9yZWNlbnRseV9wb3BwZWQKKworICAgIGRlZiBoYW5kbGVfc3RhcnR0YWcoc2VsZiwgbmFtZSwgbmFtZXNwYWNlLCBuc3ByZWZpeCwgYXR0cnMpOgorICAgICAgICAiIiJQdXNoIGEgc3RhcnQgdGFnIG9uIHRvIHRoZSBzdGFjay4KKworICAgICAgICBJZiB0aGlzIG1ldGhvZCByZXR1cm5zIE5vbmUsIHRoZSB0YWcgd2FzIHJlamVjdGVkIGJ5IHRoZQorICAgICAgICBTb3VwU3RyYWluZXIuIFlvdSBzaG91bGQgcHJvY2VlZCBhcyBpZiB0aGUgdGFnIGhhZCBub3Qgb2NjdXJlZAorICAgICAgICBpbiB0aGUgZG9jdW1lbnQuIEZvciBpbnN0YW5jZSwgaWYgdGhpcyB3YXMgYSBzZWxmLWNsb3NpbmcgdGFnLAorICAgICAgICBkb24ndCBjYWxsIGhhbmRsZV9lbmR0YWcuCisgICAgICAgICIiIgorCisgICAgICAgICMgcHJpbnQgIlN0YXJ0IHRhZyAlczogJXMiICUgKG5hbWUsIGF0dHJzKQorICAgICAgICBzZWxmLmVuZERhdGEoKQorCisgICAgICAgIGlmIChzZWxmLnBhcnNlX29ubHkgYW5kIGxlbihzZWxmLnRhZ1N0YWNrKSA8PSAxCisgICAgICAgICAgICBhbmQgKHNlbGYucGFyc2Vfb25seS50ZXh0CisgICAgICAgICAgICAgICAgIG9yIG5vdCBzZWxmLnBhcnNlX29ubHkuc2VhcmNoX3RhZyhuYW1lLCBhdHRycykpKToKKyAgICAgICAgICAgIHJldHVybiBOb25lCisKKyAgICAgICAgdGFnID0gVGFnKHNlbGYsIHNlbGYuYnVpbGRlciwgbmFtZSwgbmFtZXNwYWNlLCBuc3ByZWZpeCwgYXR0cnMsCisgICAgICAgICAgICAgICAgICBzZWxmLmN1cnJlbnRUYWcsIHNlbGYuX21vc3RfcmVjZW50X2VsZW1lbnQpCisgICAgICAgIGlmIHRhZyBpcyBOb25lOgorICAgICAgICAgICAgcmV0dXJuIHRhZworICAgICAgICBpZiBzZWxmLl9tb3N0X3JlY2VudF9lbGVtZW50OgorICAgICAgICAgICAgc2VsZi5fbW9zdF9yZWNlbnRfZWxlbWVudC5uZXh0X2VsZW1lbnQgPSB0YWcKKyAgICAgICAgc2VsZi5fbW9zdF9yZWNlbnRfZWxlbWVudCA9IHRhZworICAgICAgICBzZWxmLnB1c2hUYWcodGFnKQorICAgICAgICByZXR1cm4gdGFnCisKKyAgICBkZWYgaGFuZGxlX2VuZHRhZyhzZWxmLCBuYW1lLCBuc3ByZWZpeD1Ob25lKToKKyAgICAgICAgI3ByaW50ICJFbmQgdGFnOiAiICsgbmFtZQorICAgICAgICBzZWxmLmVuZERhdGEoKQorICAgICAgICBzZWxmLl9wb3BUb1RhZyhuYW1lLCBuc3ByZWZpeCkKKworICAgIGRlZiBoYW5kbGVfZGF0YShzZWxmLCBkYXRhKToKKyAgICAgICAgc2VsZi5jdXJyZW50X2RhdGEuYXBwZW5kKGRhdGEpCisKKyAgICBkZWYgZGVjb2RlKHNlbGYsIHByZXR0eV9wcmludD1GYWxzZSwKKyAgICAgICAgICAgICAgIGV2ZW50dWFsX2VuY29kaW5nPURFRkFVTFRfT1VUUFVUX0VOQ09ESU5HLAorICAgICAgICAgICAgICAgZm9ybWF0dGVyPSJtaW5pbWFsIik6CisgICAgICAgICIiIlJldHVybnMgYSBzdHJpbmcgb3IgVW5pY29kZSByZXByZXNlbnRhdGlvbiBvZiB0aGlzIGRvY3VtZW50LgorICAgICAgICBUbyBnZXQgVW5pY29kZSwgcGFzcyBOb25lIGZvciBlbmNvZGluZy4iIiIKKworICAgICAgICBpZiBzZWxmLmlzX3htbDoKKyAgICAgICAgICAgICMgUHJpbnQgdGhlIFhNTCBkZWNsYXJhdGlvbgorICAgICAgICAgICAgZW5jb2RpbmdfcGFydCA9ICcnCisgICAgICAgICAgICBpZiBldmVudHVhbF9lbmNvZGluZyAhPSBOb25lOgorICAgICAgICAgICAgICAgIGVuY29kaW5nX3BhcnQgPSAnIGVuY29kaW5nPSIlcyInICUgZXZlbnR1YWxfZW5jb2RpbmcKKyAgICAgICAgICAgIHByZWZpeCA9IHUnPD94bWwgdmVyc2lvbj0iMS4wIiVzPz5cbicgJSBlbmNvZGluZ19wYXJ0CisgICAgICAgIGVsc2U6CisgICAgICAgICAgICBwcmVmaXggPSB1JycKKyAgICAgICAgaWYgbm90IHByZXR0eV9wcmludDoKKyAgICAgICAgICAgIGluZGVudF9sZXZlbCA9IE5vbmUKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIGluZGVudF9sZXZlbCA9IDAKKyAgICAgICAgcmV0dXJuIHByZWZpeCArIHN1cGVyKEJlYXV0aWZ1bFNvdXAsIHNlbGYpLmRlY29kZSgKKyAgICAgICAgICAgIGluZGVudF9sZXZlbCwgZXZlbnR1YWxfZW5jb2RpbmcsIGZvcm1hdHRlcikKKworIyBBbGlhcyB0byBtYWtlIGl0IGVhc2llciB0byB0eXBlIGltcG9ydDogJ2Zyb20gYnM0IGltcG9ydCBfc291cCcKK19zID0gQmVhdXRpZnVsU291cAorX3NvdXAgPSBCZWF1dGlmdWxTb3VwCisKK2NsYXNzIEJlYXV0aWZ1bFN0b25lU291cChCZWF1dGlmdWxTb3VwKToKKyAgICAiIiJEZXByZWNhdGVkIGludGVyZmFjZSB0byBhbiBYTUwgcGFyc2VyLiIiIgorCisgICAgZGVmIF9faW5pdF9fKHNlbGYsICphcmdzLCAqKmt3YXJncyk6CisgICAgICAgIGt3YXJnc1snZmVhdHVyZXMnXSA9ICd4bWwnCisgICAgICAgIHdhcm5pbmdzLndhcm4oCisgICAgICAgICAgICAnVGhlIEJlYXV0aWZ1bFN0b25lU291cCBjbGFzcyBpcyBkZXByZWNhdGVkLiBJbnN0ZWFkIG9mIHVzaW5nICcKKy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GVjaWZpYyA9IHNlbGYuY2RhdGFfbGlzdF9hdHRyaWJ1dGVzLmdldCgKKyAgICAgICAgICAgICAgICB0YWdfbmFtZS5sb3dlcigpLCBOb25lKQorICAgICAgICAgICAgZm9yIGF0dHIgaW4gYXR0cnMua2V5cygpOgorICAgICAgICAgICAgICAgIGlmIGF0dHIgaW4gdW5pdmVyc2FsIG9yICh0YWdfc3BlY2lmaWMgYW5kIGF0dHIgaW4gdGFnX3NwZWNpZmljKToKKyAgICAgICAgICAgICAgICAgICAgIyBXZSBoYXZlIGEgImNsYXNzIi10eXBlIGF0dHJpYnV0ZSB3aG9zZSBzdHJpbmcKKyAgICAgICAgICAgICAgICAgICAgIyB2YWx1ZSBpcyBhIHdoaXRlc3BhY2Utc2VwYXJhdGVkIGxpc3Qgb2YKKyAgICAgICAgICAgICAgICAgICAgIyB2YWx1ZXMuIFNwbGl0IGl0IGludG8gYSBsaXN0LgorICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IGF0dHJzW2F0dHJdCisgICAgICAgICAgICAgICAgICAgIGlmIGlzaW5zdGFuY2UodmFsdWUsIGJhc2VzdHJpbmcpOgorICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzID0gd2hpdGVzcGFjZV9yZS5zcGxpdCh2YWx1ZSkKKyAgICAgICAgICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICAgICAgICAgICMgaHRtbDVsaWIgc29tZXRpbWVzIGNhbGxzIHNldEF0dHJpYnV0ZXMgdHdpY2UKKyAgICAgICAgICAgICAgICAgICAgICAgICMgZm9yIHRoZSBzYW1lIHRhZyB3aGVuIHJlYXJyYW5naW5nIHRoZSBwYXJzZQorICAgICAgICAgICAgICAgICAgICAgICAgIyB0cmVlLiBPbiB0aGUgc2Vjb25kIGNhbGwgdGhlIGF0dHJpYnV0ZSB2YWx1ZQorICAgICAgICAgICAgICAgICAgICAgICAgIyBoZXJlIGlzIGFscmVhZHkgYSBsaXN0LiAgSWYgdGhpcyBo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gYXdheSAobnMsIG5vZGVOYW1lKSBmb3Igbm93LgorICAgICAgICBzZWxmLnN0YXJ0RWxlbWVudChub2RlTmFtZSwgYXR0cnMpCisKKyAgICBkZWYgZW5kRWxlbWVudE5TKHNlbGYsIG5zVHVwbGUsIG5vZGVOYW1lKToKKyAgICAgICAgIyBUaHJvdyBhd2F5IChucywgbm9kZU5hbWUpIGZvciBub3cuCisgICAgICAgIHNlbGYuZW5kRWxlbWVudChub2RlTmFtZSkKKyAgICAgICAgI2hhbmRsZXIuZW5kRWxlbWVudE5TKChucywgbm9kZS5ub2RlTmFtZSksIG5vZGUubm9kZU5hbWUpCisKKyAgICBkZWYgc3RhcnRQcmVmaXhNYXBwaW5nKHNlbGYsIHByZWZpeCwgbm9kZVZhbHVlKToKKyAgICAgICAgIyBJZ25vcmUgdGhlIHByZWZpeCBmb3Igbm93LgorICAgICAgICBwYXNzCisKKyAgICBkZWYgZW5kUHJlZml4TWFwcGluZyhzZWxmLCBwcmVmaXgpOgorICAgICAgICAjIElnbm9yZSB0aGUgcHJlZml4IGZvciBub3cuCisgICAgICAgICMgaGFuZGxlci5lbmRQcmVmaXhNYXBwaW5nKHByZWZpeCkKKyAgICAgICAgcGFzcworCisgICAgZGVmIGNoYXJhY3RlcnMoc2VsZiwgY29udGVudCk6CisgICAgICAgIHNlbGYuc291cC5oYW5kbGVfZGF0YShjb250ZW50KQorCisgICAgZGVmIHN0YXJ0RG9jdW1lbnQoc2VsZik6CisgICAgICAgIHBhc3MKKworICAgIGRlZiBlbmREb2N1bWVudChzZWxmKToKKyAgICAgICAgcGFzcworCisKK2NsYXNzIEhUTUxUcmVlQnVpbGRlcihUcmVlQnVpbGRlcik6CisgICAgIiIiVGhpcyBUcmVlQnVpbGRlciBrbm93cyBmYWN0cyBhYm91dCBIVE1MLgorCisgICAgU3VjaCBhcyB3aGljaCB0YWdzIGFyZSBlbXB0eS1lbGVtZW50IHRhZ3MuCisgICAgIiIiCisKKyAgICBwcmVzZXJ2ZV93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HRoYXQgcHJvdmlkZSB0aGUgImNvbnRlbnQiCisgICAgICAgICMgYXR0cmlidXRlIGFuZCBoYXZlICJodHRwLWVxdWl2IiBzZXQgdG8gImNvbnRlbnQtdHlwZSIuCisgICAgICAgICMKKyAgICAgICAgIyBJbiBib3RoIGNhc2VzIHdlIHdpbGwgcmVwbGFjZSB0aGUgdmFsdWUgb2YgdGhlIGFwcHJvcHJpYXRlCisgICAgICAgICMgYXR0cmlidXRlIHdpdGggYSBzdGFuZGluIG9iamVjdCB0aGF0IGNhbiB0YWtlIG9uIGFueQorICAgICAgICAjIGVuY29kaW5nLgorICAgICAgICBtZXRhX2VuY29kaW5nID0gTm9uZQorICAgICAgICBpZiBjaGFyc2V0IGlzIG5vdCBOb25lOgorICAgICAgICAgICAgIyBIVE1MIDUgc3R5bGU6CisgICAgICAgICAgICAjIDxtZXRhIGNoYXJzZXQ9InV0ZjgiPgorICAgICAgICAgICAgbWV0YV9lbmNvZGluZyA9IGNoYXJzZXQKKyAgICAgICAgICAgIHRhZ1snY2hhcnNldCddID0gQ2hhcnNldE1ldGFBdHRyaWJ1dGVWYWx1ZShjaGFyc2V0KQorCisgICAgICAgIGVsaWYgKGNvbnRlbnQgaXMgbm90IE5vbmUgYW5kIGh0dHBfZXF1aXYgaXMgbm90IE5vbmUKKyAgICAgICAgICAgICAgYW5kIGh0dHBfZXF1aXYubG93ZXIoKSA9PSAnY29udGVudC10eXBlJyk6CisgICAgICAgICAgICAjIEhUTUwgNCBzdHlsZToKKyAgICAgICAgICAgICMgPG1ldGEgaHR0cC1lcXVpdj0iY29udGVudC10eXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9dXRmOCI+CisgICAgICAgICAgICB0YWdbJ2NvbnRlbnQnXSA9IENvbnRlbnRNZXRhQXR0cmlidXRlVmFsdWUoY29udGVudCkKKworICAgICAgICByZXR1cm4gKG1ldGFfZW5jb2RpbmcgaXMgbm90IE5vbmUpCisKK2RlZiByZWdpc3R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GF0YSksIHNlbGYuc291cCkKKworICAgIGRlZiBmcmFnbWVudENsYXNzKHNlbGYpOgorICAgICAgICBzZWxmLnNvdXAgPSBCZWF1dGlmdWxTb3VwKCIiKQorICAgICAgICBzZWxmLnNvdXAubmFtZSA9ICJbZG9jdW1lbnRfZnJhZ21lbnRdIgorICAgICAgICByZXR1cm4gRWxlbWVudChzZWxmLnNvdXAsIHNlbGYuc291cCwgTm9uZSkKKworICAgIGRlZiBhcHBlbmRDaGlsZChzZWxmLCBub2RlKToKKyAgICAgICAgIyBYWFggVGhpcyBjb2RlIGlzIG5vdCBjb3ZlcmVkIGJ5IHRoZSBCUzQgdGVzdHMuCisgICAgICAgIHNlbGYuc291cC5hcHBlbmQobm9kZS5lbGVtZW50KQorCisgICAgZGVmIGdldERvY3VtZW50KHNlbGYpOgorICAgICAgICByZXR1cm4gc2VsZi5zb3VwCisKKyAgICBkZWYgZ2V0RnJhZ21lbnQoc2VsZik6CisgICAgICAgIHJldHVybiBodG1sNWxpYi50cmVlYnVpbGRlcnMuX2Jhc2UuVHJlZUJ1aWxkZXIuZ2V0RnJhZ21lbnQoc2VsZikuZWxlbWVudAorCitjbGFzcyBBdHRyTGlzdChvYmplY3QpOgorICAgIGRlZiBfX2luaXRfXyhzZWxmLCBlbGVtZW50KToKKyAgICAgICAgc2VsZi5lbGVtZW50ID0gZWxlbWVudAorICAgICAgICBzZWxmLmF0dHJzID0gZGljdChzZWxmLmVsZW1lbnQuYXR0cnMpCisgICAgZGVmIF9faXRlcl9fKHNlbGYpOgorICAgICAgICByZXR1cm4gbGlzdChzZWxmLmF0dHJzLml0ZW1zKCkpLl9faXRlcl9fKCkKKyAgICBkZWYgX19zZXRpdGVtX18oc2VsZiwgbmFtZSwgdmFsdWUpOgorICAgICAgICAic2V0IGF0dHIiLCBuYW1lLCB2YWx1ZQorICAgICAgICBzZWxmLmVsZW1lbnRbbmFtZV0gPSB2YWx1ZQorICAgIGRlZiBpdGVtcyhzZWxmKToKKyAgICAg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IG9sZF9lbGVtZW50ID0gc2VsZi5lbGVtZW50LmNvbnRlbnRzWy0xXQorICAgICAgICAgICAgbmV3X2VsZW1lbnQgPSBzZWxmLnNvdXAubmV3X3N0cmluZyhvbGRfZWxlbWVudCArIHN0cmluZ19jaGlsZCkKKyAgICAgICAgICAgIG9sZF9lbGVtZW50LnJlcGxhY2Vfd2l0aChuZXdfZWxlbWVudCkKKyAgICAgICAgICAgIHNlbGYuc291cC5fbW9zdF9yZWNlbnRfZWxlbWVudCA9IG5ld19lbGVtZW50CisgICAgICAgIGVsc2U6CisgICAgICAgICAgICBpZiBpc2luc3RhbmNlKG5vZGUsIGJhc2VzdHJpbmcpOgorICAgICAgICAgICAgICAgICMgQ3JlYXRlIGEgYnJhbmQgbmV3IE5hdmlnYWJsZVN0cmluZyBmcm9tIHRoaXMgc3RyaW5nLgorICAgICAgICAgICAgICAgIGNoaWxkID0gc2VsZi5zb3VwLm5ld19zdHJpbmcobm9kZSkKKworICAgICAgICAgICAgIyBUZWxsIEJlYXV0aWZ1bCBTb3VwIHRvIGFjdCBhcyBpZiBpdCBwYXJzZWQgdGhpcyBlbGVtZW50CisgICAgICAgICAgICAjIGltbWVkaWF0ZWx5IGFmdGVyIHRoZSBwYXJlbnQncyBsYXN0IGRlc2NlbmRhbnQuIChPcgorICAgICAgICAgICAgIyBpbW1lZGlhdGVseSBhZnRlciB0aGUgcGFyZW50LCBpZiBpdCBoYXMgbm8gY2hpbGRyZW4uKQorICAgICAgICAgICAgaWYgc2VsZi5lbGVtZW50LmNvbnRlbnRzOgorICAgICAgICAgICAgICAgIG1vc3RfcmVjZW50X2VsZW1lbnQgPSBzZWxmLmVsZW1lbnQuX2xhc3RfZGVzY2VuZGFudChGYWxzZSkKKyAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAgICAgICAgbW9zdF9yZWNlbnRfZWxlbWVudCA9IHNlbGYuZWxlbWVudAorCisgICAgICAgICAgICBzZWxmLnNvdXAub2JqZWN0X3dhc19wYXJzZWQoCisgICAgICAgICAgICAgICAgY2hpbGQsIHBhcmVudD1zZWxmLmVsZW1lbnQsCisgICAgICAgICAgICAgICAgbW9zdF9yZWNlbnRfZWxlbWVudD1tb3N0X3JlY2VudF9lbGVtZW50KQorCisgICAgZGVmIGdldEF0dHJpYnV0ZXMoc2VsZik6CisgICAgICAgIHJldHVybiBBdHRyTGlzdChzZWxmLmVsZW1lbnQpCisKKyAgICBkZWYgc2V0QXR0cmlidXRlcyhzZWxmLCBhdHRyaWJ1dGVzKToKKyAgICAgICAgaWYgYXR0cmlidXRlcyBpcyBub3QgTm9uZSBhbmQgbGVuKGF0dHJpYnV0ZXMpID4gMDoKKworICAgICAgICAgICAgY29udmVydGVkX2F0dHJpYnV0ZXMgPSBbXQorICAgICAgICAgICAgZm9yIG5hbWUsIHZhbHVlIGluIGxpc3QoYXR0cmlidXRlcy5pdGVtcygpKToKKyAgICAgICAgICAgICAgICBpZiBpc2luc3RhbmNlKG5hbWUsIHR1cGxlKToKKyAgICAgICAgICAgICAgICAgICAgbmV3X25hbWUgPSBOYW1lc3BhY2VkQXR0cmlidXRlKCpuYW1lKQorICAgICAgICAgICAgICAgICAgICBkZWwgYXR0cmlidXRlc1tuYW1lXQorICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzW25ld19uYW1lXSA9IHZhbHVlCisKKyAgICAgICAgICAgIHNlbGYuc291cC5idWlsZGVyLl9yZXBsYWNlX2NkYXRhX2xpc3RfYXR0cmlidXRlX3ZhbHVlcygKKyAgICAgICAgICAgICAgICBzZWxmLm5hbWUsIGF0dHJpYnV0ZXMpCisgICAgICAgICAgICBmb3IgbmFtZSwgdmFsdWUgaW4gYXR0cmlidXRlcy5pdGVtcygpOgorICAgICAgICAgICAgICAgIHNlbGYuZWxlbWVudFtuYW1lXSA9IHZhbHVlCisKKyAgICAgICAgICAgICMgVGhlIGF0dHJpYnV0ZXMgbWF5IGNvbnRhaW4gdmFyaWFibGVzIHRoYXQgbmVlZCBzdWJzdGl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QorICAgICAgICBpZiBsZW4obmV3X3BhcmVudF9lbGVtZW50LmNvbnRlbnRzKSA+IDA6CisgICAgICAgICAgICAjIFRoZSBuZXcgcGFyZW50IGFscmVhZHkgY29udGFpbnMgY2hpbGRyZW4uIFdlIHdpbGwgYmUKKyAgICAgICAgICAgICMgYXBwZW5kaW5nIHRoaXMgdGFnJ3MgY2hpbGRyZW4gdG8gdGhlIGVuZC4KKyAgICAgICAgICAgIG5ld19wYXJlbnRzX2xhc3RfY2hpbGQgPSBuZXdfcGFyZW50X2VsZW1lbnQuY29udGVudHNbLTFdCisgICAgICAgICAgICBuZXdfcGFyZW50c19sYXN0X2Rlc2NlbmRhbnRfbmV4dF9lbGVtZW50ID0gbmV3X3BhcmVudHNfbGFzdF9kZXNjZW5kYW50Lm5leHRfZWxlbWVudAorICAgICAgICBlbHNlOgorICAgICAgICAgICAgIyBUaGUgbmV3IHBhcmVudCBjb250YWlucyBubyBjaGlsZHJlbi4KKyAgICAgICAgICAgIG5ld19wYXJlbnRzX2xhc3RfY2hpbGQgPSBOb25lCisgICAgICAgICAgICBuZXdfcGFyZW50c19sYXN0X2Rlc2NlbmRhbnRfbmV4dF9lbGVtZW50ID0gbmV3X3BhcmVudF9lbGVtZW50Lm5leHRfZWxlbWVudAorCisgICAgICAgIHRvX2FwcGVuZCA9IGVsZW1lbnQuY29udGVudHMKKyAgICAgICAgYXBwZW5kX2FmdGVyID0gbmV3X3BhcmVudC5lbGVtZW50LmNvbnRlbnRzCisgICAgICAgIGlmIGxlbih0b19hcHBlbmQpID4gMDoKKyAgICAgICAgICAgICMgU2V0IHRoZSBmaXJzdCBjaGlsZCdzIHByZXZpb3VzX2VsZW1lbnQgYW5kIHByZXZpb3VzX3NpYmxpbmcKKyAgICAgICAgICAgICMgdG8gZWxlbWVudHMgd2l0aGluIHRoZSBuZXcgcGFyZW50CisgICAgICAgICAgICBmaXJzdF9jaGlsZCA9IHRvX2FwcGVuZFswXQorICAgICAgICAgICAgZmlyc3RfY2hpbGQucHJldmlvdXNfZWxlbWVudCA9IG5ld19wYXJlbnRzX2xhc3RfZGVzY2VuZGFudAorICAgICAgICAgICAgZmlyc3RfY2hpbGQucHJldmlvdXNfc2libGluZyA9IG5ld19wYXJlbnRzX2xhc3RfY2hpbGQKKworICAgICAgICAgICAgIyBGaXggdGhlIGxhc3QgY2hpbGQncyBuZXh0X2VsZW1lbnQgYW5kIG5leHRfc2libGluZworICAgICAgICAgICAgbGFzdF9jaGlsZCA9IHRvX2FwcGVuZFstMV0KKyAgICAgICAgICAgIGxhc3RfY2hpbGQubmV4dF9lbGVtZW50ID0gbmV3X3BhcmVudHNfbGFzdF9kZXNjZW5kYW50X25leHRfZWxlbWVudAorICAgICAgICAgICAgbGFzdF9jaGlsZC5uZXh0X3NpYmxpbmcgPSBOb25lCisKKyAgICAgICAgZm9yIGNoaWxkIGluIHRvX2FwcGVuZDoKKyAgICAgICAgICAgIGNoaWxkLnBhcmVudCA9IG5ld19wYXJlbnRfZWxlbWVudAorICAgICAgICAgICAgbmV3X3BhcmVudF9lbGVtZW50LmNvbnRlbnRzLmFwcGVuZChjaGlsZCkKKworICAgICAgICAjIE5vdyB0aGF0IHRoaXMgZWxlbWVudCBoYXMgbm8gY2hpbGRyZW4sIGNoYW5nZSBpdHMgLm5leHRfZWxlbWVudC4KKyAgICAgICAgZWxlbWVudC5jb250ZW50cyA9IFtdCisgICAgICAgIGVsZW1lbnQubmV4dF9lbGVtZW50ID0gZmluYWxfbmV4dF9lbGVtZW50CisKKyAgICBkZWYgY2xvbmVOb2RlKHNlbGYpOgorICAgICAgICB0YWcgPSBzZWxmLnNvdXAubmV3X3RhZyhzZWxmLmVsZW1lbnQubmFtZSwgc2VsZi5uYW1lc3BhY2UpCisgICAgICAgIG5vZGUgPSBFbGVtZW50KHRhZywgc2VsZi5zb3VwLCBzZWxmLm5hbWVzcGFjZSkKKyAgICAgICAgZm9yIGtleSx2YWx1ZSBpbiBzZWxmLmF0dHJpYnV0ZXM6CisgICAgICAgICAgICBub2RlLmF0dHJpYnV0ZXNba2V5XSA9IHZhbHVlCisgICAgICAgIHJldHVybiBub2RlCisKKyAgICBkZWYgaGFzQ29udGVudChzZWxmKToKKyAgICAgICAgcmV0dXJuIHNlbGYuZWxlbWVudC5jb250ZW50cworCisgICAgZGVmIGdldE5hbWVUdXBsZShzZWxmKToKKyAgICAgICAgaWYgc2VsZi5uYW1lc3BhY2UgPT0gTm9uZToKKyAgICAgICAgICAgIHJldHVybiBuYW1lc3BhY2VzWyJodG1sIl0sIHNlbGYubmFtZQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgcmV0dXJuIHNlbGYubmFtZXNwYWNlLCBzZWxmLm5hbWUKKworICAgIG5hbWVUdXBsZSA9IHByb3BlcnR5KGdldE5hbWVUdXBsZSkKKworY2xhc3MgVGV4dE5vZGUoRWxlbWVudCk6CisgICAgZGVmIF9faW5pdF9fKHNlbGYsIGVsZW1lbnQsIHNvdXApOgorICAgICAgICBodG1sNWxpYi50cmVlYnVpbGRlcnMuX2Jhc2UuTm9kZS5fX2luaXRfXyhzZWxmLCBOb25lKQorICAgICAgICBzZWxmLmVsZW1lbnQgPSBlbGVtZW50CisgICAgICAgIHNlbGYuc291cCA9IHNvdXAKKworICAgIGRlZiBjbG9uZU5vZGUoc2VsZik6CisgICAgICAgIHJhaXNlIE5vdEltcGxlbWVudGVkRXJyb3IKZGlmZiAtLWdpdCBhL2JpdGJha2UvbGliL2JzNC9idWlsZGVyL19odG1scGFyc2VyLnB5IGIvYml0YmFrZS9saWIvYnM0L2J1aWxkZXIvX2h0bWxwYXJzZXIucHkKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uY2E4ZDhiOAotLS0gL2Rldi9udWxsCisrKyBiL2JpdGJha2UvbGliL2JzNC9idWlsZGVyL19odG1scGFyc2VyLnB5CkBAIC0wLDAgKzEsMjU4IEBACisiIiJVc2UgdGhlIEhUTUxQYXJzZXIgbGlicmFyeSB0byBwYX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VuZERhdGEoKQorICAgICAgICBzZWxmLnNvdXAuaGFuZGxlX2RhdGEoZGF0YSkKKyAgICAgICAgc2VsZi5zb3VwLmVuZERhdGEoQ29tbWVudCkKKworICAgIGRlZiBoYW5kbGVfZGVjbChzZWxmLCBkYXRhKToKKyAgICAgICAgc2VsZi5zb3VwLmVuZERhdGEoKQorICAgICAgICBpZiBkYXRhLnN0YXJ0c3dpdGgoIkRPQ1RZUEUgIik6CisgICAgICAgICAgICBkYXRhID0gZGF0YVtsZW4oIkRPQ1RZUEUgIik6XQorICAgICAgICBlbGlmIGRhdGEgPT0gJ0RPQ1RZUEUnOgorICAgICAgICAgICAgIyBpLmUuICI8IURPQ1RZUEU+IgorICAgICAgICAgICAgZGF0YSA9ICcnCisgICAgICAgIHNlbGYuc291cC5oYW5kbGVfZGF0YShkYXRhKQorICAgICAgICBzZWxmLnNvdXAuZW5kRGF0YShEb2N0eXBlKQorCisgICAgZGVmIHVua25vd25fZGVjbChzZWxmLCBkYXRhKToKKyAgICAgICAgaWYgZGF0YS51cHBlcigpLnN0YXJ0c3dpdGgoJ0NEQVRBWycpOgorICAgICAgICAgICAgY2xzID0gQ0RhdGEKKyAgICAgICAgICAgIGRhdGEgPSBkYXRhW2xlbignQ0RBVEFbJyk6XQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgY2xzID0gRGVjbGFyYXRpb24KKyAgICAgICAgc2VsZi5zb3VwLmVuZERhdGEoKQorICAgICAgICBzZWxmLnNvdXAuaGFuZGxlX2RhdGEoZGF0YSkKKyAgICAgICAgc2VsZi5zb3VwLmVuZERhdGEoY2xzKQorCisgICAgZGVmIGhhbmRsZV9waShzZWxmLCBkYXRhKToKKyAgICAgICAgc2VsZi5zb3VwLmVuZERhdGEoKQorICAgICAgICBpZiBkYXRhLmVuZHN3aXRoKCI/IikgYW5kIGRhdGEubG93ZXIoKS5zdGFydHN3aXRoKCJ4bWwiKToKKyAgICAgICAgICAgICMgIkFuIFhIVE1MIHByb2Nlc3NpbmcgaW5zdHJ1Y3Rpb24gdXNpbmcgdGhlIHRyYWlsaW5nICc/JworICAgICAgICAgICAgIyB3aWxsIGNhdXNlIHRoZSAnPycgdG8gYmUgaW5jbHVkZWQgaW4gZGF0YS4iIC0gSFRNTFBhcnNlcgorICAgICAgICAgICAgIyBkb2NzLgorICAgICAgICAgICAgIworICAgICAgICAgICAgIyBTdHJpcCB0aGUgcXVlc3Rpb24gbWFyayBzbyB3ZSBkb24ndCBlbmQgdXAgd2l0aCB0d28KKyAgICAgICAgICAgICMgcXVlc3Rpb24gbWFya3MuCisgICAgICAgICAgICBkYXRhID0gZGF0YVs6LTFdCisgICAgICAgIHNlbGYuc291cC5oYW5kbGVfZGF0YShkYXRhKQorICAgICAgICBzZWxmLnNvdXAuZW5kRGF0YShQcm9jZXNzaW5nSW5zdHJ1Y3Rpb24pCisKKworY2xhc3MgSFRNTFBhcnNlclRyZWVCdWlsZGVyKEhUTUxUcmVlQnVpbGRlcik6CisKKyAgICBpc194bWwgPSBGYWxzZQorICAgIGZlYXR1cmVzID0gW0hUTUwsIFNUUklDVCwgSFRNTFBBUlNFUl0KKworICAgIGRlZiBfX2luaXRfXyhzZWxmLCAqYXJncywgKiprd2FyZ3MpOgorICAgICAgICBpZiBDT05TVFJVQ1RPUl9UQUtFU19TVFJJQ1Q6CisgICAgICAgICAgICBrd2FyZ3NbJ3N0cmljdCddID0gRmFsc2UKKyAgICAgICAgc2VsZi5wYXJzZXJfYXJncyA9IChhcmdzLCBrd2FyZ3MpCisKKyAgICBkZWYgcHJlcGFyZV9tYXJrdXAoc2VsZiwgbWFya3VwLCB1c2VyX3NwZWNpZmllZF9lbmNvZGluZz1Ob25lLAorICAgICAgICAgICAgICAgICAgICAgICBkb2N1bWVudF9kZWNsYXJlZF9lbmNvZGluZz1Ob25lKToKKyAgICAgICAgIiIiCisgICAgICAgIDpyZXR1cm46IEEgNC10dXBsZSAobWFya3VwLCBvcmlnaW5hbCBlbmNvZGluZywgZW5jb2RpbmcK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mluZF90b2xlcmFudCA9IGF0dHJmaW5kX3RvbGVyYW50CisKKyAgICBsb2NhdGVzdGFydHRhZ2VuZCA9IHJlLmNvbXBpbGUociIiIgorICA8W2EtekEtWl1bLS5hLXpBLVowLTk6X10qICAgICAgICAgICMgdGFnIG5hbWUKKyAgKD86XHMrICAgICAgICAgICAgICAgICAgICAgICAgICAgICAjIHdoaXRlc3BhY2UgYmVmb3JlIGF0dHJpYnV0ZSBuYW1lCisgICAgKD86W2EtekEtWl9dWy0uOmEtekEtWjAtOV9dKiAgICAgIyBhdHRyaWJ1dGUgbmFtZQorICAgICAgKD86XHMqPVxzKiAgICAgICAgICAgICAgICAgICAgICMgdmFsdWUgaW5kaWNhdG9yCisgICAgICAgICg/OidbXiddKicgICAgICAgICAgICAgICAgICAgIyBMSVRBLWVuY2xvc2VkIHZhbHVlCisgICAgICAgICAgfFwiW15cIl0qXCIgICAgICAgICAgICAgICAgIyBMSVQtZW5jbG9zZWQgdmFsdWUKKyAgICAgICAgICB8W14nXCI+XHNdKyAgICAgICAgICAgICAgICAjIGJhcmUgdmFsdWUKKyAgICAgICAgICkKKyAgICAgICApPworICAgICApCisgICApKgorICBccyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgdHJhaWxpbmcgd2hpdGVzcGFjZQorIiIiLCByZS5WRVJCT1NFKQorICAgIEJlYXV0aWZ1bFNvdXBIVE1MUGFyc2VyLmxvY2F0ZXN0YXJ0dGFnZW5kID0gbG9jYXRlc3RhcnR0YWdlbmQKKworICAgIGZyb20gaHRtbC5wYXJzZXIgaW1wb3J0IHRhZ2ZpbmQsIGF0dHJmaW5kCisKKyAgICBkZWYgcGFyc2Vfc3RhcnR0YWcoc2VsZiwgaSk6CisgICAgICAgIHNlbGYuX19zdGFydHRhZ190ZXh0ID0gTm9uZQorICAgICAgICBlbmRwb3MgPSBzZWxmLmNoZWNrX2Zvcl93aG9sZV9zdGFydF90YWcoaSkKKyAgICAgICAgaWYgZW5kcG9zIDwgMDoKKyAgICAgICAgICAgIHJldHVybiBlbmRwb3MKKyAgICAgICAgcmF3ZGF0YSA9IHNlbGYucmF3ZGF0YQorICAgICAgICBzZWxmLl9fc3RhcnR0YWdfdGV4dCA9IHJhd2RhdGFbaTplbmRwb3NdCisKKyAgICAgICAgIyBOb3cgcGFyc2UgdGhlIGRhdGEgYmV0d2VlbiBpKzEgYW5kIGogaW50byBhIHRhZyBhbmQgYXR0cnMKKyAgICAgICAgYXR0cnMgPSBbXQorICAgICAgICBtYXRjaCA9IHRhZ2ZpbmQubWF0Y2gocmF3ZGF0YSwgaSsxKQorICAgICAgICBhc3NlcnQgbWF0Y2gsICd1bmV4cGVjdGVkIGNhbGwgdG8gcGFyc2Vfc3RhcnR0YWcoKScKKyAgICAgICAgayA9IG1hdGNoLmVuZCgpCisgICAgICAgIHNlbGYubGFzdHRhZyA9IHRhZyA9IHJhd2RhdGFbaSsxOmtdLmxvd2VyKCkKKyAgICAgICAgd2hpbGUgayA8IGVuZHBvczoKKyAgICAgICAgICAgIGlmIHNlbGYuc3RyaWN0OgorICAgICAgICAgICAgICAgIG0gPSBhdHRyZmluZC5tYXRjaChyYXdkYXRhLCBrKQorICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICBtID0gYXR0cmZpbmRfdG9sZXJhbnQubWF0Y2gocmF3ZGF0YSwgaykKKyAgICAgICAgICAgIGlmIG5vdCBtOgorICAgICAgICAgICAgICAgIGJyZWFrCisgICAgICAgICAgICBhdHRybmFtZSwgcmVzdCwgYXR0cnZhbHVlID0gbS5ncm91cCgxLCAyLCAzKQorICAgICAgICAgICAgaWYgbm90IHJlc3Q6CisgICAgICAgICAgICAgICAgYXR0cnZhbHVlID0gTm9uZQorICAgICAgICAgICAgZWxpZiBhdHRydmFsdWVbOjFdID09ICdcJycgPT0gYXR0cnZhbHVlWy0xOl0gb3IgXAorICAgICAgICAgICAgICAgICBhdHRydmFsdWVbOjFdID09ICciJyA9PSBhdHRydmFsdWVbLTE6XToKKyAgICAgICAgICAgICAgICBhdHRydmFsdWUgPSBhdHRydmFsdWVbMTotMV0KKyAgICAgICAgICAgIGlmIGF0dHJ2YWx1ZToKKyAgICAgICAgICAgICAgICBhdHRydmFsdWUgPSBzZWxmLnVuZXNjYXBlKGF0dHJ2YWx1ZSkKKyAgICAgICAgICAgIGF0dHJzLmFwcGVuZCgoYXR0cm5hbWUubG93ZXIoKSwgYXR0cnZhbHVlKSkKKyAgICAgICAgICAgIGsgPSBtLmVuZCgpCisKKyAgICAgICAgZW5kID0gcmF3ZGF0YVtrOmVuZHBvc10uc3RyaXAoKQorICAgICAgICBpZiBlbmQgbm90IGluICgiPiIsICIvPiIpOgorICAgICAgICAgICAgbGluZW5vLCBvZmZzZXQgPSBzZWxmLmdldHBvcygpCisgICAgICAgICAgICBpZiAiXG4iIGluIHNlbGYuX19zdGFydHRhZ190ZXh0OgorICAgICAgICAgICAgICAgIGxpbmVubyA9IGxpbmVubyArIHNlbGYuX19zdGFydHRhZ190ZXh0LmNvdW50KCJcbiIpCisgICAgICAgICAgICAgICAgb2Zmc2V0ID0gbGVuKHNlbGYuX19zdGFydHRhZ190ZXh0KSBcCisgICAgICAgICAgICAgICAgICAgICAgICAgLSBzZWxmLl9fc3RhcnR0YWdfdGV4dC5yZmluZCgiXG4iKQorICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICBvZmZzZXQgPSBvZmZzZXQgKyBsZW4oc2VsZi5fX3N0YXJ0dGFnX3RleHQpCisgICAgICAgICAgICBpZiBzZWxmLnN0cmljdDoKKyAgICAgICAgICAgICAgICBzZWxmLmVycm9yKCJqdW5rIGNoYXJhY3RlcnMgaW4gc3RhcnQgdGFnOiAlciIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICUgKHJhd2RhdGFbazplbmRwb3NdWzoyMF0sKSkKKyAgICAgICAgICAgIHNlbGYuaGFuZGxlX2RhdGEocmF3ZGF0YVtpOmVuZHBvc10pCisgICAgICAgICAgICByZXR1cm4gZW5kc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wYXJzZXIgaXMgcHJlc2VudCBidXQgbm90IGEKKyAgICAgICAgIyBjYWxsYWJsZSwgc2luY2UgdGhhdCBtZWFucyB0aGVyZSdzIG5vIHdheSB0byBjcmVhdGUgbmV3CisgICAgICAgICMgcGFyc2VycyBmb3IgZGlmZmVyZW50IGVuY29kaW5ncy4KKyAgICAgICAgc2VsZi5fZGVmYXVsdF9wYXJzZXIgPSBwYXJzZXIKKyAgICAgICAgaWYgZW1wdHlfZWxlbWVudF90YWdzIGlzIG5vdCBOb25lOgorICAgICAgICAgICAgc2VsZi5lbXB0eV9lbGVtZW50X3RhZ3MgPSBzZXQoZW1wdHlfZWxlbWVudF90YWdzKQorICAgICAgICBzZWxmLnNvdXAgPSBOb25lCisgICAgICAgIHNlbGYubnNtYXBzID0gW3NlbGYuREVGQVVMVF9OU01BUFNdCisKKyAgICBkZWYgX2dldE5zVGFnKHNlbGYsIHRhZyk6CisgICAgICAgICMgU3BsaXQgdGhlIG5hbWVzcGFjZSBVUkwgb3V0IG9mIGEgZnVsbHktcXVhbGlmaWVkIGx4bWwgdGFnCisgICAgICAgICMgbmFtZS4gQ29waWVkIGZyb20gbHhtbCdzIHNyYy9seG1sL3NheC5weS4KKyAgICAgICAgaWYgdGFnWzBdID09ICd7JzoKKyAgICAgICAgICAgIHJldHVybiB0dXBsZSh0YWdbMTpdLnNwbGl0KCd9JywgMSkpCisgICAgICAgIGVsc2U6CisgICAgICAgICAgICByZXR1cm4gKE5vbmUsIHRhZykKKworICAgIGRlZiBwcmVwYXJlX21hcmt1cChzZWxmLCBtYXJrdXAsIHVzZXJfc3BlY2lmaWVkX2VuY29kaW5nPU5vbmUsCisgICAgICAgICAgICAgICAgICAgICAgIGRvY3VtZW50X2RlY2xhcmVkX2VuY29kaW5nPU5vbmUpOgorICAgICAgICAiIiIKKyAgICAgICAgOnlpZWxkOiBBIHNlcmllcyBvZiA0LXR1cGxlcy4KKyAgICAgICAgIChtYXJrdXAsIGVuY29kaW5nLCBkZWNsYXJlZCBlbmNvZGluZywKKyAgICAgICAgICBoYXMgdW5kZXJnb25lIGNoYXJhY3RlciByZXBsYWNlbWVudCkKKworICAgICAgICBFYWNoIDQtdHVwbGUgcmVwcmVzZW50cyBhIHN0cmF0ZWd5IGZvciBwYXJzaW5nIHRoZSBkb2N1bWVudC4KKyAgICAgICAgIiIiCisgICAgICAgIGlmIGlzaW5zdGFuY2UobWFya3VwLCB1bmljb2RlKToKKyAgICAgICAgICAgICMgV2Ugd2VyZSBnaXZlbiBVbmljb2RlLiBNYXliZSBseG1sIGNhbiBwYXJzZSBVbmljb2RlIG9uCisgICAgICAgICAgICAjIHRoaXMgc3lzdGVtPworICAgICAgICAgICAgeWllbGQgbWFya3VwLCBOb25lLCBkb2N1bWVudF9kZWNsYXJlZF9lbmNvZGluZywgRmFsc2UKKworICAgICAgICBpZiBpc2luc3RhbmNlKG1hcmt1cCwgdW5pY29kZSk6CisgICAgICAgICAgICAjIE5vLCBhcHBhcmVudGx5IG5vdC4gQ29udmVydCB0aGUgVW5pY29kZSB0byBVVEYtOCBhbmQKKyAgICAgICAgICAgICMgdGVsbCBseG1sIHRvIHBhcnNlIGl0IGFzIFVURi04LgorICAgICAgICAgICAgeWllbGQgKG1hcmt1cC5lbmNvZGUoInV0ZjgiKSwgInV0ZjgiLAorICAgICAgICAgICAgICAgICAgIGRvY3VtZW50X2RlY2xhcmVkX2VuY29kaW5nLCBGYWxzZSkKKworICAgICAgICAjIEluc3RlYWQgb2YgdXNpbmcgVW5pY29kZURhbW1pdCB0byBjb252ZXJ0IHRoZSBieXRlc3RyaW5nIHRvCisgICAgICAgICMgVW5pY29kZSB1c2luZyBkaWZmZXJlbnQgZW5jb2RpbmdzLCB1c2UgRW5jb2RpbmdEZXRlY3RvciB0bworICAgICAgICAjIGl0ZXJhdGUgb3ZlciB0aGUgZW5jb2RpbmdzLCBhbmQgdGVsbCBseG1sIHRvIHRyeSB0byBwYXJzZQorICAgICAgICAjIHRoZSBkb2N1bWVudCBhc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IyBzZXBhcmF0ZSB0YWcgc3RhY2sgdG8ga25vdyB3aGVuIHRoZXkgZW5kLgorICAgICAgICAgICAgc2VsZi5uc21hcHMuYXBwZW5kKE5vbmUpCisgICAgICAgIGVsaWYgbGVuKG5zbWFwKSA+IDA6CisgICAgICAgICAgICAjIEEgbmV3IG5hbWVzcGFjZSBtYXBwaW5nIGhhcyBjb21lIGludG8gcGxheS4KKyAgICAgICAgICAgIGludmVydGVkX25zbWFwID0gZGljdCgodmFsdWUsIGtleSkgZm9yIGtleSwgdmFsdWUgaW4gbnNtYXAuaXRlbXMoKSkKKyAgICAgICAgICAgIHNlbGYubnNtYXBzLmFwcGVuZChpbnZlcnRlZF9uc21hcCkKKyAgICAgICAgICAgICMgQWxzbyB0cmVhdCB0aGUgbmFtZXNwYWNlIG1hcHBpbmcgYXMgYSBzZXQgb2YgYXR0cmlidXRlcyBvbiB0aGUKKyAgICAgICAgICAgICMgdGFnLCBzbyB3ZSBjYW4gcmVjcmVhdGUgaXQgbGF0ZXIuCisgICAgICAgICAgICBhdHRycyA9IGF0dHJzLmNvcHkoKQorICAgICAgICAgICAgZm9yIHByZWZpeCwgbmFtZXNwYWNlIGluIG5zbWFwLml0ZW1zKCk6CisgICAgICAgICAgICAgICAgYXR0cmlidXRlID0gTmFtZXNwYWNlZEF0dHJpYnV0ZSgKKyAgICAgICAgICAgICAgICAgICAgInhtbG5zIiwgcHJlZml4LCAiaHR0cDovL3d3dy53My5vcmcvMjAwMC94bWxucy8iKQorICAgICAgICAgICAgICAgIGF0dHJzW2F0dHJpYnV0ZV0gPSBuYW1lc3BhY2UKKworICAgICAgICAjIE5hbWVzcGFjZXMgYXJlIGluIHBsYXkuIEZpbmQgYW55IGF0dHJpYnV0ZXMgdGhhdCBjYW1lIGluCisgICAgICAgICMgZnJvbSBseG1sIHdpdGggbmFtZXNwYWNlcyBhdHRhY2hlZCB0byB0aGVpciBuYW1lcywgYW5kCisgICAgICAgICMgdHVybiB0aGVuIGludG8gTmFt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lcnNlZChzZWxmLm5zbWFwcyk6CisgICAgICAgICAgICBpZiBpbnZlcnRlZF9uc21hcCBpcyBub3QgTm9uZSBhbmQgbmFtZXNwYWNlIGluIGludmVydGVkX25zbWFwOgorICAgICAgICAgICAgICAgIHJldHVybiBpbnZlcnRlZF9uc21hcFtuYW1lc3BhY2VdCisgICAgICAgIHJldHVybiBOb25lCisKKyAgICBkZWYgZW5kKHNlbGYsIG5hbWUpOgorICAgICAgICBzZWxmLnNvdXAuZW5kRGF0YSgpCisgICAgICAgIGNvbXBsZXRlZF90YWcgPSBzZWxmLnNvdXAudGFnU3RhY2tbLTFdCisgICAgICAgIG5hbWVzcGFjZSwgbmFtZSA9IHNlbGYuX2dldE5zVGFnKG5hbWUpCisgICAgICAgIG5zcHJlZml4ID0gTm9uZQorICAgICAgICBpZiBuYW1lc3BhY2UgaXMgbm90IE5vbmU6CisgICAgICAgICAgICBmb3IgaW52ZXJ0ZWRfbnNtYXAgaW4gcmV2ZXJzZWQoc2VsZi5uc21hcHMpOgorICAgICAgICAgICAgICAgIGlmIGludmVydGVkX25zbWFwIGlzIG5vdCBOb25lIGFuZCBuYW1lc3BhY2UgaW4gaW52ZXJ0ZWRfbnNtYXA6CisgICAgICAgICAgICAgICAgICAgIG5zcHJlZml4ID0gaW52ZXJ0ZWRfbnNtYXBbbmFtZXNwYWNlXQorICAgICAgICAgICAgICAgICAgICBicmVhaworICAgICAgICBzZWxmLnNvdXAuaGFuZGxlX2VuZHRhZyhuYW1lLCBuc3ByZWZpeCkKKyAgICAgICAgaWYgbGVuKHNlbGYubnNtYXBzKSA+IDE6CisgICAgICAgICAgICAjIFRoaXMgdGFnLCBvciBvbmUgb2YgaXRzIHBhcmVudHMsIGludHJvZHVjZWQgYSBuYW1lc3BhY2UKKyAgICAgICAgICAgICMgbWFwcGluZywgc28gcG9wIGl0IG9mZiB0aGUgc3RhY2suCisgICAgICAgICAgICBzZWxmLm5zbWFwcy5wb3AoKQorCisgICAgZGVmIHBpKHN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AgICAgICAjaW1wb3J0IGNoYXJkZXQuY29uc3RhbnRzCisgICAgICAgICNjaGFyZGV0LmNvbnN0YW50cy5fZGVidWcgPSAxCisgICAgZXhjZXB0IEltcG9ydEVycm9yOgorICAgICAgICAjIE5vIGNoYXJkZXQgYXZhaWxhYmxlLgorICAgICAgICBkZWYgY2hhcmRldF9kYW1taXQocyk6CisgICAgICAgICAgICByZXR1cm4gTm9uZQorCisjIEF2YWlsYWJsZSBmcm9tIGh0dHA6Ly9jamtweXRob24uaTE4bi5vcmcvLgordHJ5OgorICAgIGltcG9ydCBpY29udl9jb2RlYworZXhjZXB0IEltcG9ydEVycm9yOgorICAgIHBhc3MKKworeG1sX2VuY29kaW5nX3JlID0gcmUuY29tcGlsZSgKKyAgICAnXjxcPy4qZW5jb2Rpbmc9W1wnIl0oLio/KVtcJyJdLipcPz4nLmVuY29kZSgpLCByZS5JKQoraHRtbF9tZXRhX3JlID0gcmUuY29tcGlsZSgKKyAgICAnPFxzKm1ldGFbXj5dK2NoYXJzZXRccyo9XHMqWyJcJ10/KFtePl0qPylbIC87XCciPl0nLmVuY29kZSgpLCByZS5JKQorCitjbGFzcyBFbnRpdHlTdWJzdGl0dXRpb24ob2JqZWN0KToKKworICAgICIiIlN1YnN0aXR1dGUgWE1MIG9yIEhUTUwgZW50aXRpZXMgZm9yIHRoZSBjb3JyZXNwb25kaW5nIGNoYXJhY3RlcnMuIiIiCisKKyAgICBkZWYgX3BvcHVsYXRlX2NsYXNzX3ZhcmlhYmxlcygpOgorICAgICAgICBsb29rdXAgPSB7fQorICAgICAgICByZXZlcnNlX2xvb2t1cCA9IHt9CisgICAgICAgIGNoYXJhY3RlcnNfZm9yX3JlID0gW10KKyAgICAgICAgZm9yIGNvZGVwb2ludCwgbmFtZSBpbiBsaXN0KGNvZGVwb2ludDJuYW1lLml0ZW1zKCkpOgorICAgICAgICAgICAgY2hhcmFjdGVyID0gdW5pY2hyKGNvZGVwb2ludCkKKyAgICAgICAgICAgIGlmIGNvZGVwb2ludCAhPSAzNDoKKyAgICAgICAgICAgICAgICAjIFRoZXJlJ3Mgbm8gcG9pbnQgaW4gdHVybmluZyB0aGUgcXVvdGF0aW9uIG1hcmsgaW50bworICAgICAgICAgICAgICAgICMgJnF1b3Q7LCB1bmxlc3MgaXQgaGFwcGVucyB3aXRoaW4gYW4gYXR0cmlidXRlIHZhbHVlLCB3aGljaAorICAgICAgICAgICAgICAgICMgaXMgaGFuZGxlZCBlbHNld2hlcmUuCisgICAgICAgICAgICAgICAgY2hhcmFjdGVyc19mb3JfcmUuYXBwZW5kKGNoYXJhY3RlcikKKyAgICAgICAgICAgICAgICBsb29rdXBbY2hhcmFjdGVyXSA9IG5hbWUKKyAgICAgICAgICAgICMgQnV0IHdlIGRvIHdhbnQgdG8gdHVybiAmcXVvdDsgaW50byB0aGUgcXVvdGF0aW9uIG1hcmsuCisgICAgICAgICAgICByZXZlcnNlX2xvb2t1cFtuYW1lXSA9IGNoYXJhY3RlcgorICAgICAgICByZV9kZWZpbml0aW9uID0gIlslc10iICUgIiIuam9pbihjaGFyYWN0ZXJzX2Zvcl9yZSkKKyAgICAgICAgcmV0dXJuIGxvb2t1cCwgcmV2ZXJzZV9sb29rdXAsIHJlLmNvbXBpbGUocmVfZGVmaW5pdGlvbikKKyAgICAoQ0hBUkFDVEVSX1RPX0hUTUxfRU5USVRZLCBIVE1MX0VOVElUWV9UT19DSEFSQUNURVIsCisgICAgIENIQVJBQ1RFUl9UT19IVE1MX0VOVElUWV9SRSkgPSBfcG9wdWxhdGVfY2xhc3NfdmFyaWFibGVzKCkKKworICAgIENIQVJBQ1RFUl9UT19YTUxfRU5USVRZID0geworICAgICAgICAiJyI6ICJhcG9zIiwKKyAgICAgICAgJyInOiAicXVvdCIsCisgICAgICAgICImIjogImFtcCIsCisgICAgICAgICI8IjogImx0IiwKKyAgICAgICAgIj4iOiAiZ3QiLAorICAgICAgICB9CisKKyAgICBCQVJFX0FNUEVSU0FORF9PUl9CUkFDS0VUID0gcmUuY29tcGlsZSgiKFs8Pl18IgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICImKD8hI1xkKzt8I3hbMC05YS1mQS1GXSs7fFx3KzspIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIpIikKKworICAgIEFNUEVSU0FORF9PUl9CUkFDS0VUID0gcmUuY29tcGlsZSgiKFs8PiZdKSIpCisKKyAgICBAY2xhc3NtZXRob2QKKyAgICBkZWYgX3N1YnN0aXR1dGVfaHRtbF9lbnRpdHkoY2xzLCBtYXRjaG9iaik6CisgICAgICAgIGVudGl0eSA9IGNscy5DSEFSQUNURVJfVE9fSFRNTF9FTlRJVFkuZ2V0KG1hdGNob2JqLmdyb3VwKDApKQorICAgICAgICByZXR1cm4gIiYlczsiICUgZW50aXR5CisKKyAgICBAY2xhc3NtZXRob2QKKyAgICBkZWYgX3N1YnN0aXR1dGVfeG1sX2VudGl0eShjbHMsIG1hdGNob2JqKToKKyAgICAgICAgIiIiVXNlZCB3aXRoIGEgcmVndWxhciBleHByZXNzaW9uIHRvIHN1YnN0aXR1dGUgdGhlCisgICAgICAgIGFwcHJvcHJpYXRlIFhNTCBlbnRpdHkgZm9yIGFuIFhNTCBzcGVjaWFsIGNoYXJhY3Rlci4iIiIKKyAgICAgICAgZW50aXR5ID0gY2xzLkNIQVJBQ1RFUl9UT19YTUxfRU5USVRZW21hdGNob2JqLmdyb3VwKDApXQorICAgICAgICByZXR1cm4gIiYlczsiICUgZW50aXR5CisKKyAgICBAY2xhc3NtZXRob2QKKyAgICBkZWYgcXVvdGVkX2F0dHJpYnV0ZV92YWx1ZShzZWxmLCB2YWx1ZSk6CisgICAgICAgICIiIk1ha2UgYSB2YWx1ZSBpbnRvIGEgcXVvdGVkIFhNTCBhdHRyaWJ1dGUsIHBvc3NpYmx5IGVzY2FwaW5nIGl0LgorCisgICAgICAgICBNb3N0IHN0cmluZ3Mgd2lsbCBiZSBxdW90ZWQgdXNpbmcgZG91YmxlIHF1b3Rlcy4KKworICAgICAgICAgIEJvYidzIEJhciAtPiAiQm9iJ3MgQmFyIgorCisgICAgICAgICBJZiBhIHN0cmluZyBjb250YWlucyBkb3VibGUgcXVvdGVzLCBpdCB3aWxsIGJlIHF1b3RlZCB1c2luZworICAgICAgICAgc2luZ2xlIHF1b3Rlcy4KKworICAgICAgICAgIFdlbGNvbWUgdG8gIm15IGJhciIgLT4gJ1dlbGNvbWUgdG8gIm15IGJhciInCisKKyAgICAgICAgIElmIGEgc3RyaW5nIGNvbnRhaW5zIGJvdGggc2luZ2xlIGFuZCBkb3VibGUgcXVvdGVzLCB0aGUKKyAgICAgICAgIGRvdWJsZSBxdW90ZXMgd2lsbCBiZSBlc2NhcGVkLCBhbmQgdGhlIHN0cmluZyB3aWxsIGJlIHF1b3RlZAorICAgICAgICAgdXNpbmcgZG91YmxlIHF1b3Rlcy4KKworICAgICAgICAgIFdlbGNvbWUgdG8gIkJvYidzIEJhciIgLT4gIldlbGNvbWUgdG8gJnF1b3Q7Qm9iJ3MgYmFyJnF1b3Q7CisgICAgICAgICIiIgorICAgICAgICBxdW90ZV93aXRoID0gJyInCisgICAgICAgIGlmICciJyBpbiB2YWx1ZToKKyAgICAgICAgICAgIGlmICInIiBpbiB2YWx1ZToKKyAgICAgICAgICAgICAgICAjIFRoZSBzdHJpbmcgY29udGFpbnMgYm90aCBzaW5nbGUgYW5kIGRvdWJsZQorICAgICAgICAgICAgICAgICMgcXVvdGVzLiAgVHVybiB0aGUgZG91YmxlIHF1b3RlcyBpbnRvCisgICAgICAgICAgICAgICAgIyBlbnRpdGllcy4gV2UgcXVvdGUgdGhlIGRvdWJsZSBxdW90ZXMgcmF0aGVyIHRoYW4KKyAgICAgICAgICAgICAgICAjIHRoZSBzaW5nbGUgcXVvdGVzIGJlY2F1c2UgdGhlIGVudGl0eSBuYW1lIGlzCisgICAgICAgICAgICAgICAgIyAiJnF1b3Q7IiB3aGV0aGVyIHRoaXMgaXMgSF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AgICAgICAgICAgICAgcmV0dXJuIFRydWUKKyAgICAgICAgcmV0dXJuIEZhbHNlCisKKyAgICBAcHJvcGVydHkKKyAgICBkZWYgZW5jb2RpbmdzKHNlbGYpOgorICAgICAgICAiIiJZaWVsZCBhIG51bWJlciBvZiBlbmNvZGluZ3MgdGhhdCBtaWdodCB3b3JrIGZvciB0aGlzIG1hcmt1cC4iIiIKKyAgICAgICAgdHJpZWQgPSBzZXQoKQorICAgICAgICBmb3IgZSBpbiBzZWxmLm92ZXJyaWRlX2VuY29kaW5nczoKKyAgICAgICAgICAgIGlmIHNlbGYuX3VzYWJsZShlLCB0cmllZCk6CisgICAgICAgICAgICAgICAgeWllbGQgZQorCisgICAgICAgICMgRGlkIHRoZSBkb2N1bWVudCBvcmlnaW5hbGx5IHN0YXJ0IHdpdGggYSBieXRlLW9yZGVyIG1hcmsKKyAgICAgICAgIyB0aGF0IGluZGljYXRlZCBpdHMgZW5jb2Rpbmc/CisgICAgICAgIGlmIHNlbGYuX3VzYWJsZShzZWxmLnNuaWZmZWRfZW5jb2RpbmcsIHRyaWVkKToKKyAgICAgICAgICAgIHlpZWxkIHNlbGYuc25pZmZlZF9lbmNvZGluZworCisgICAgICAgICMgTG9vayB3aXRoaW4gdGhlIGRvY3VtZW50IGZvciBhbiBYTUwgb3IgSFRNTCBlbmNvZGluZworICAgICAgICAjIGRlY2xhcmF0aW9uLgorICAgICAgICBpZiBzZWxmLmRlY2xhcmVkX2VuY29kaW5nIGlzIE5vbmU6CisgICAgICAgICAgICBzZWxmLmRlY2xhcmVkX2VuY29kaW5nID0gc2VsZi5maW5kX2RlY2xhcmVkX2VuY29kaW5nKAorICAgICAgICAgICAgICAgIHNlbGYubWFya3VwLCBzZWxmLmlzX2h0bWwpCisgICAgICAgIGlmIHNlbGYuX3VzYWJsZShzZWxmLmRlY2xhcmVkX2VuY29kaW5nLCB0cmllZCk6CisgICAgICAgICAgICB5aWVsZCBzZWxmLmRlY2xhcmVkX2VuY29kaW5nCisKKyAgICAgICAgIyBVc2UgdGhpcmQtcGFydHkgY2hhcmFjdGVyIHNldCBkZXRlY3Rpb24gdG8gZ3Vlc3MgYXQgdGhlCisgICAgICAgICMgZW5jb2RpbmcuCisgICAgICAgIGlmIHNlbGYuY2hhcmRldF9lbmNvZGluZyBpcyBOb25lOgorICAgICAgICAgICAgc2VsZi5jaGFyZGV0X2VuY29kaW5nID0gY2hhcmRldF9kYW1taXQoc2VsZi5tYXJrdXApCisgICAgICAgIGlmIHNlbGYuX3VzYWJsZShzZWxmLmNoYXJkZXRfZW5jb2RpbmcsIHRyaWVkKToKKyAgICAgICAgICAgIHlpZWxkIHNlbGYuY2hhcmRldF9lbmNvZGluZworCisgICAgICAgICMgQXMgYSBsYXN0LWRpdGNoIGVmZm9ydCwgdHJ5IHV0Zi04IGFuZCB3aW5kb3dzLTEyNTIuCisgICAgICAgIGZvciBlIGluICgndXRmLTgnLCAnd2luZG93cy0xMjUyJyk6CisgICAgICAgICAgICBpZiBzZWxmLl91c2FibGUoZSwgdHJpZWQpOgorICAgICAgICAgICAgICAgIHlpZWxkIGUKKworICAgIEBjbGFzc21ldGhvZAorICAgIGRlZiBzdHJpcF9ieXRlX29yZGVyX21hcmsoY2xzLCBkYXRhKToKKyAgICAgICAgIiIiSWYgYSBieXRlLW9yZGVyIG1hcmsgaXMgcHJlc2VudCwgc3RyaXAgaXQgYW5kIHJldHVybiB0aGUgZW5jb2RpbmcgaXQgaW1wbGllcy4iIiIKKyAgICAgICAgZW5jb2RpbmcgPSBOb25lCisgICAgICAgIGlmIChsZW4oZGF0YSkgPj0gNCkgYW5kIChkYXRhWzoyXSA9PSBiJ1x4ZmVceGZmJykgXAorICAgICAgICAgICAgICAgYW5kIChkYXRhWzI6NF0gIT0gJ1x4MDBceDAwJyk6CisgICAgICAgICAgICBlbmNvZGluZyA9ICd1dGYtMTZiZScKKyAgICAgICAgICAgIGRhdGEgPSBkYXRhWzI6XQorICAgICAgICBlbGlmIChsZW4oZGF0YSkg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ICAgaWYgbm90IHU6CisgICAgICAgICAgICAjIE5vbmUgb2YgdGhlIGVuY29kaW5ncyB3b3JrZWQuIEFzIGFuIGFic29sdXRlIGxhc3QgcmVzb3J0LAorICAgICAgICAgICAgIyB0cnkgdGhlbSBhZ2FpbiB3aXRoIGNoYXJhY3RlciByZXBsYWNlbWVudC4KKworICAgICAgICAgICAgZm9yIGVuY29kaW5nIGluIHNlbGYuZGV0ZWN0b3IuZW5jb2RpbmdzOgorICAgICAgICAgICAgICAgIGlmIGVuY29kaW5nICE9ICJhc2NpaSI6CisgICAgICAgICAgICAgICAgICAgIHUgPSBzZWxmLl9jb252ZXJ0X2Zyb20oZW5jb2RpbmcsICJyZXBsYWNlIikKKyAgICAgICAgICAgICAgICBpZiB1IGlzIG5vdCBOb25lOgorICAgICAgICAgICAgICAgICAgICBsb2dnaW5nLndhcm5pbmcoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlNvbWUgY2hhcmFjdGVycyBjb3VsZCBub3QgYmUgZGVjb2RlZCwgYW5kIHdlcmUgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJyZXBsYWNlZCB3aXRoIFJFUExBQ0VNRU5UIENIQVJBQ1RFUi4iKQorICAgICAgICAgICAgICAgICAgICBzZWxmLmNvbnRhaW5zX3JlcGxhY2VtZW50X2NoYXJhY3RlcnMgPSBUcnVlCisgICAgICAgICAgICAgICAgICAgIGJyZWFrCisKKyAgICAgICAgIyBJZiBub25lIG9mIHRoYXQgd29ya2VkLCB3ZSBjb3VsZCBhdCB0aGlzIHBvaW50IGZvcmNlIGl0IHRvCisgICAgICAgICMgQVNDSUksIGJ1dCB0aGF0IHdvdWxkIGRlc3Ryb3kgc28gbXVjaCBkYXRhIHRoYXQgSSB0aGluaworICAgICAgICAjIGdpdmluZyB1cCBpcyBiZXR0ZXIuCisgICAgICAgIHNlbGYudW5pY29kZV9tYXJrdXAgPSB1CisgICAgICAgIGlmIG5vdCB1OgorICAgICAgICAgICAgc2VsZi5v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AgI3ByaW50ICJUaGF0IGRpZG4ndCB3b3JrISIKKyAgICAgICAgICAgICNwcmludCBlCisgICAgICAgICAgICByZXR1cm4gTm9uZQorICAgICAgICAjcHJpbnQgIkNvcnJlY3QgZW5jb2Rpbmc6ICVzIiAlIHByb3Bvc2VkCisgICAgICAgIHJldHVybiBzZWxmLm1hcmt1cAorCisgICAgZGVmIF90b191bmljb2RlKHNlbGYsIGRhdGEsIGVuY29kaW5nLCBlcnJvcnM9InN0cmljdCIpOgorICAgICAgICAnJydHaXZlbiBhIHN0cmluZyBhbmQgaXRzIGVuY29kaW5nLCBkZWNvZGVzIHRoZSBzdHJpbmcgaW50byBVbmljb2RlLgorICAgICAgICAlZW5jb2RpbmcgaXMgYSBzdHJpbmcgcmVjb2duaXplZCBieSBlbmNvZGluZ3MuYWxpYXNlcycnJworICAgICAgICByZXR1cm4gdW5pY29kZShkYXRhLCBlbmNvZGluZywgZXJyb3JzKQorCisgICAgQHByb3BlcnR5CisgICAgZGVmIGRlY2xhcmVkX2h0bWxfZW5jb2Rpbmcoc2VsZik6CisgICAgICAgIGlmIG5vdCBzZWxmLmlzX2h0bWw6CisgICAgICAgICAgICByZXR1cm4gTm9uZQorICAgICAgICByZXR1cm4gc2VsZi5kZXRlY3Rvci5kZWNsYXJlZF9lbmNvZGluZworCisgICAgZGVmIGZpbmRfY29kZWMoc2VsZiwgY2hhcnNldCk6CisgICAgICAgIHZhbHVlID0gKHNlbGYuX2NvZGVjKHNlbGYuQ0hBUlNFVF9BTElBU0VTLmdldChjaGFyc2V0LCBjaGFyc2V0KSkKKyAgICAgICAgICAgICAgIG9yIChjaGFyc2V0IGFuZCBzZWxmLl9jb2RlYyhjaGFyc2V0LnJlcGxhY2UoIi0iLCAiIikpKQorICAgICAgICAgICAgICAgb3IgKGNoYXJzZXQgYW5kIHNlbGYuX2NvZGVjKGNoYXJzZXQucmVwbGFjZSgiLSIsICJfIikpKQorICAgICAgICAgICAgICAgb3IgKGNoYXJzZXQgYW5kIGNoYXJzZXQubG93ZXIoKSkKKyAgICAgICAgICAgICAgIG9yIGNoYXJzZXQKKyAgICAgICAgICAgICAgICApCisgICAgICAgIGlmIHZhbHVlOgorICAgICAgICAgICAgcmV0dXJuIHZhbHVlLmxvd2VyKCkKKyAgICAgICAgcmV0dXJuIE5vbmUKKworICAgIGRlZiBfY29kZWMoc2VsZiwgY2hhcnNldCk6CisgICAgICAgIGlmIG5vdCBjaGFyc2V0OgorICAgICAgICAgICAgcmV0dXJuIGNoYXJzZXQKKyAgICAgICAgY29kZWMgPSBOb25lCisgICAgICAgIHRyeToKKyAgICAgICAgICAgIGNvZGVjcy5sb29rdXAoY2hhcnNldCkKKyAgICAgICAgICAgIGNvZGVjID0gY2hhcnNldAorICAgICAgICBleGNlcHQgKExvb2t1cEVycm9yLCBWYWx1ZUVycm9yKToKKyAgICAgICAgICAgIHBhc3MKKyAgICAgICAgcmV0dXJuIGNvZGVjCisKKworICAgICMgQSBwYXJ0aWFsIG1hcHBpbmcgb2YgSVNPLUxhdGluLTEgdG8gSFRNTCBlbnRpdGllcy9YTUwgbnVtZXJpYyBlbnRpdGllcy4KKyAgICBNU19DSEFSUyA9IHtiJ1x4ODAnOiAoJ2V1cm8nLCAnMjBBQycpLAorICAgICAgICAgICAgICAgIGInXHg4MSc6ICcgJywKKyAgICAgICAgICAgICAgICBiJ1x4ODInOiAoJ3NicXVvJywgJzIwMUEnKSwKKyAgICAgICAgICAgICAgICBiJ1x4ODMnOiAoJ2Zub2YnLCAnMTkyJyksCisgICAgICAgICAgICAgICAgYidceDg0JzogKCdiZHF1bycsICcyMDFFJyksCisgICAgICAgICAgICAgICAgYidceDg1JzogKCdoZWxsaXAnLCAnMjAyNicpLAorICAgICAgICAgICAgICAgIGInXHg4Nic6ICgnZGFnZ2VyJywgJzIwMjAnKSwKKyAgICAgICAgICAgICAgICBiJ1x4ODcnOiAoJ0RhZ2dlcicsICcyMDIxJyksCisgICAgICAgICAgICAgICAgYidceDg4JzogKCdjaXJjJywgJzJDNicpLAorICAgICAgICAgICAgICAgIGInXHg4OSc6ICgncGVybWlsJywgJzIwMzAnKSwKKyAgICAgICAgICAgICAgICBiJ1x4OEEnOiAoJ1NjYXJvbicsICcxNjAnKSwKKyAgICAgICAgICAgICAgICBiJ1x4OEInOiAoJ2xzYXF1bycsICcyMDM5JyksCisgICAgICAgICAgICAgICAgYidceDhDJzogKCdPRWxpZycsICcxNTInKSwKKyAgICAgICAgICAgICAgICBiJ1x4OEQnOiAnPycsCisgICAgICAgICAgICAgICAgYidceDhFJzogKCcjeDE3RCcsICcxN0QnKSwKKyAgICAgICAgICAgICAgICBiJ1x4OEYnOiAnPycsCisgICAgICAgICAgICAgICAgYidceDkwJzogJz8nLAorICAgICAgICAgICAgICAgIGInXHg5MSc6ICgnbHNxdW8nLCAnMjAxOCcpLAorICAgICAgICAgICAgICAgIGInXHg5Mic6ICgncnNxdW8nLCAnMjAxOScpLAorICAgICAgICAgICAgICAgIGInXHg5Myc6ICgnbGRxdW8nLCAnMjAxQycpLAorICAgICAgICAgICAgICAgIGInXHg5NCc6ICgncmRxdW8nLCAnMjAxRCcpLAorICAgICAgICAgICAgICAgIGInXHg5NSc6ICgnYnVsbCcsICcyMDIyJyksCisgICAgICAgICAgICAgICAgYidceDk2JzogKCduZGFzaCcsICcyMDEzJyksCisgICAgICAgICAgICAgICAgYidceDk3JzogKCdtZGFzaCcsICcyMDE0JyksCisgICAgICAgICAgICAgICAgYidceDk4JzogKCd0aWxkZScsICcyREMnKSwKKyAgICAgICAgICAgICAgICBiJ1x4OTknOiAoJ3RyYWRlJywgJzIxMjInKSwKKyAgICAgICAgICAgICAgICBiJ1x4OWEnOiAoJ3NjYXJvbicsICcxNjEnKSwKKyAgICAgICAgICAgICAgICBiJ1x4OWInOiAoJ3JzYXF1bycsICcyMDNBJyksCisgICAgICAgICAgICAgICAgYidceDljJzogKCdvZWxpZycsICcxNTMnKSwKKyAgICAgICAgICAgICAgICBiJ1x4OWQnOiAnPycsCisgICAgICAgICAgICAgICAgYidceDllJzogKCcjeDE3RScsICcxN0UnKSwKKyAgICAgICAgICAgICAgICBiJ1x4OWYnOiAoJ1l1bWwnLCAnJyksfQorCisgICAgIyBBIHBhcm9jaGlhbCBwYXJ0aWFsIG1hcHBpbmcgb2YgSVNPLUxhdGluLTEgdG8gQVNDSUkuIENvbnRhaW5zCisgICAgIyBob3Jyb3JzIGxpa2Ugc3RyaXBwaW5nIGRpYWNyaXRpY2FsIG1hcmtzIHRvIHR1cm4gw6EgaW50byBhLCBidXQgYWxzbworICAgICMgY29udGFpbnMgbm9uLWhvcnJvcnMgbGlrZSB0dXJuaW5nIOKAnCBpbnRvICIuCisgICAgTVNfQ0hBUlNfVE9fQVNDSUkgPSB7CisgICAgICAgIGInXHg4MCcgOiAnRVVSJywKKyAgICAgICAgYidceDgxJyA6ICcgJywKKyAgICAgICAgYidceDgyJyA6ICcsJywKKyAgICAgICAgYidceDgzJyA6ICdmJywKKyAgICAgICAgYidceDg0JyA6ICcsLCcsCisgICAgICAgIGInXHg4NScgOiAnLi4uJywKKyAgICAgICAgYidceDg2JyA6ICcrJywKKyAgICAgICAgYidceDg3JyA6ICcrKycsCisgICAgICAgIGInXHg4OCcgOiAnXicsCisgICAgICAgIGInXHg4OScgOiAnJScsCisgICAgICAgIGInXHg4YScgOiAnUycsCisgICAgICAgIGInXHg4YicgOiAnPCcsCisgICAgICAgIGInXHg4YycgOiAnT0UnLAorICAgICAgICBiJ1x4OGQnIDogJz8nLAorICAgICAgICBiJ1x4OGUnIDogJ1onLAorICAgICAgICBiJ1x4OGYnIDogJz8nLAorICAgICAgICBiJ1x4OTAnIDogJz8nLAorICAgICAgICBiJ1x4OTEnIDogIiciLAorICAgICAgICBiJ1x4OTInIDogIiciLAorICAgICAgICBiJ1x4OTMnIDogJyInLAorICAgICAgICBiJ1x4OTQnIDogJyInLAorICAgICAgICBiJ1x4OTUnIDogJyonLAorICAgICAgICBiJ1x4OTYnIDogJy0nLAorICAgICAgICBiJ1x4OTcnIDogJy0tJywKKyAgICAgICAgYidceDk4JyA6ICd+JywKKyAgICAgICAgYidceDk5JyA6ICcoVE0pJywKKyAgICAgICAgYidceDlhJyA6ICdzJywKKyAgICAgICAgYidceDliJyA6ICc+JywKKyAgICAgICAgYidceDljJyA6ICdvZScsCisgICAgICAgIGInXHg5ZCcgOiAnPycsCisgICAgICAgIGInXHg5ZScgOiAneicsCisgICAgICAgIGInXHg5ZicgOiAnWScsCisgICAgICAgIGInXHhhMCcgOiAnICcsCisgICAgICAgIGInXHhhMScgOiAnIScsCisgICAgICAgIGInXHhhMicgOiAnYycsCisgICAgICAgIGInXHhhMycgOiAnR0JQJywKKyAgICAgICAgYidceGE0JyA6ICckJywgI1RoaXMgYXBwcm94aW1hdGlvbiBpcyBlc3BlY2lhbGx5IHBhcm9jaGlhbC0tdGhpcyBpcyB0aGUKKyAgICAgICAgICAgICAgICAgICAgICAgI2dlbmVyaWMgY3VycmVuY3kgc3ltYm9sLgorICAgICAgICBiJ1x4YTUnIDogJ1lFTicsCisgICAgICAgIGInXHhhNicgOiAnfCcsCisgICAgICAgIGInXHhhNycgOiAnUycsCisgICAgICAgIGInXHhhOCcgOiAnLi4nLAorICAgICAgICBiJ1x4YTknIDogJycsCisgICAgICAgIGInXHhhYScgOiAnKHRoKScsCisgICAgICAgIGInXHhhYicgOiAnPDwnLAorICAgICAgICBiJ1x4YWMnIDogJyEnLAorICAgICAgICBiJ1x4YWQnIDogJyAnLAorICAgICAgICBiJ1x4YWUnIDogJyhSKScsCisgICAgICAgIGInXHhhZicgOiAnLScsCisgICAgICAgIGInXHhiMCcgOiAnbycsCisgICAgICAgIGInXHhiMScgOiAnKy0nLAorICAgICAgICBiJ1x4YjInIDogJzInLAorICAgICAgICBiJ1x4YjMnIDogJzMnLAorICAgICAgICBiJ1x4YjQnIDogKCInIiwgJ2FjdXRlJyksCisgICAgICAgIGInXHhiNScgOiAndScsCisgICAgICAgIGInXHhiNicgOiAnUCcsCisgICAgICAgIGInXHhiNycgOiAnKicsCisgICAgICAgIGInXHhiOCcgOiAnLCcsCisgICAgICAgIGInXHhiOScgOiAnMScsCisgICAgICAgIGInXHhiYScgOiAnKHRoKScsCisgICAgICAgIGInXHhiYicgOiAnPj4nLAorICAgICAgICBiJ1x4YmMnIDogJzEvNCcsCisgICAgICAgIGInXHhiZCcgOiAnMS8yJywKKyAgICAgICAgYidceGJlJyA6ICczLzQnLAorICAgICAgICBiJ1x4YmYnIDogJz8nLAorICAgICAgICBiJ1x4YzAnIDogJ0EnLAorICAgICAgICBiJ1x4YzEnIDogJ0EnLAorICAgICAgICBiJ1x4YzInIDogJ0EnLAorICAgICAgICBiJ1x4YzMnIDogJ0EnLAorICAgICAgICBiJ1x4YzQnIDogJ0EnLAorICAgICAgICBiJ1x4YzUnIDogJ0EnLAorICAgICAgICBiJ1x4YzYnIDogJ0FFJywKKyAgICAgICAgYidceGM3JyA6ICdDJywKKyAgICAgICAgYidceGM4JyA6ICdFJywKKyAgICAgICAgYidceGM5JyA6ICdFJywKKyAgICAgICAgYidceGNhJyA6ICdFJywKKyAgICAgICAgYidceGNiJyA6ICdFJywKKyAgICAgICAgYidceGNjJyA6ICdJJywKKyAgICAgICAgYidceGNkJyA6ICdJJywKKyAgICAgICAgYidceGNlJyA6ICdJJywKKyAgICAgICAgYidceGNmJyA6ICdJJywKKyAgICAgICAgYidceGQwJyA6ICdEJywKKyAgICAgICAgYidceGQxJyA6ICdOJywKKyAgICAgICAgYidceGQyJyA6ICdPJywKKyAgICAgICAgYidceGQzJyA6ICdPJywKKyAgICAgICAgYidceGQ0JyA6ICdPJywKKyAgICAgICAgYidceGQ1JyA6ICdPJywKKyAgICAgICAgYidceGQ2JyA6ICdPJywKKyAgICAgICAgYidceGQ3JyA6ICcqJywKKyAgICAgICAgYidceGQ4JyA6ICdPJywKKyAgICAgICAgYidceGQ5JyA6ICdVJywKKyAgICAgICAgYidceGRhJyA6ICdVJywKKyAgICAgICAgYidceGRiJyA6ICdVJywKKyAgICAgICAgYidceGRjJyA6ICdVJywKKyAgICAgICAgYidceGRkJyA6ICdZJywKKyAgICAgICAgYidceGRlJyA6ICdiJywKKyAgICAgICAgYidceGRmJyA6ICdCJywKKyAgICAgICAgYidceGUwJyA6ICdhJywKKyAgICAgICAgYidceGUxJyA6ICdhJywKKyAgICAgICAgYidceGUyJyA6ICdhJywKKyAgICAgICAgYidceGUzJyA6ICdhJywKKyAgICAgICAgYidceGU0JyA6ICdhJywKKyAgICAgICAgYidceGU1JyA6ICdhJywKKyAgICAgICAgYidceGU2JyA6ICdhZScsCisgICAgICAgIGInXHhlNycgOiAnYycsCisgICAgICAgIGInXHhlOCcgOiAnZScsCisgICAgICAgIGInXHhlOScgOiAnZScsCisgICAgICAgIGInXHhlYScgOiAnZScsCisgICAgICAgIGInXHhlYicgOiAnZScsCisgICAgICAgIGInXHhlYycgOiAnaScsCisgICAgICAgIGInXHhlZCcgOiAnaScsCisgICAgICAgIGInXHhlZScgOiAnaScsCisgICAgICAgIGInXHhlZicgOiAnaScsCisgICAgICAgIGInXHhmMCcgOiAnbycsCisgICAgICAgIGInXHhmMScgOiAnbicsCisgICAgICAgIGInXHhmMicgOiAnbycsCisgICAgICAgIGInXHhmMycgOiAnbycsCisgICAgICAgIGInXHhmNCcgOiAnbycsCisgICAgICAgIGInXHhmNScgOiAnbycsCisgICAgICAgIGInXHhmNicgOiAnbycsCisgICAgICAgIGInXHhmNycgOiAnLycsCisgICAgICAgIGInXHhmOCcgOiAnbycsCisgICAgICAgIGInXHhmOScgOiAndScsCisgICAgICAgIGInXHhmYScgOiAndScsCisgICAgICAgIGInXHhmYicgOiAndScsCisgICAgICAgIGInXHhmYycgOiAndScsCisgICAgICAgIGInXHhmZCcgOiAneScsCisgICAgICAgIGInXHhmZScgOiAnYicsCisgICAgICAgIGInXHhmZicgOiAneScsCisgICAgICAgIH0KKworICAgICMgQSBtYXAgdXNlZCB3aGVuIHJlbW92aW5nIHJvZ3VlIFdpbmRvd3MtMTI1Mi9JU08tODg1OS0xCisgICAgIyBjaGFyYWN0ZXJzIGluIG90aGVyd2lzZSBVVEYtOCBkb2N1bWVudHMuCisgICAgIworICAgICMgTm90ZSB0aGF0IFx4ODEsIFx4OGQsIFx4OGYsIFx4OTAsIGFuZCBceDlkIGFyZSB1bmRlZmluZWQgaW4KKyAgICAjIFdpbmRvd3MtMTI1Mi4KKyAgICBXSU5ET1dTXzEyNTJfVE9fVVRGOCA9IHsKKyAgICAgICAgMHg4MCA6IGInXHhlMlx4ODJceGFjJywgIyDigqwKKyAgICAgICAgMHg4MiA6IGInXHhlMlx4ODBceDlhJywgIyDigJoKKyAgICAgICAgMHg4MyA6IGInXHhjNlx4OTInLCAgICAgIyDGkgorICAgICAgICAweDg0IDogYidceGUyXHg4MFx4OWUnLCAjIOKAngorICAgICAgICAweDg1IDogYidceGUyXHg4MFx4YTYnLCAjIOKApgorICAgICAgICAweDg2IDogYidceGUyXHg4MFx4YTAnLCAjIOKAoAorICAgICAgICAweDg3IDogYidceGUyXHg4MFx4YTEnLCAjIOKAoQorICAgICAgICAweDg4IDogYidceGNiXHg4NicsICAgICAjIMuGCisgICAgICAgIDB4ODkgOiBiJ1x4ZTJceDgwXHhiMCcsICMg4oCwCisgICAgICAgIDB4OGEgOiBiJ1x4YzVceGEwJywgICAgICMgxaAKKyAgICAgICAgMHg4YiA6IGInXHhlMlx4ODBceGI5JywgIyDigLkKKyAgICAgICAgMHg4YyA6IGInXHhjNVx4OTInLCAgICAgIyDFkgorICAgICAgICAweDhlIDogYidceGM1XHhiZCcsICAgICAjIMW9CisgICAgICAgIDB4OTEgOiBiJ1x4ZTJceDgwXHg5OCcsICMg4oCYCisgICAgICAgIDB4OTIgOiBiJ1x4ZTJceDgwXHg5OScsICMg4oCZCisgICAgICAgIDB4OTMgOiBiJ1x4ZTJceDgwXHg5YycsICMg4oCcCisgICAgICAgIDB4OTQgOiBiJ1x4ZTJceDgwXHg5ZCcsICMg4oCdCisgICAgICAgIDB4OTUgOiBiJ1x4ZTJceDgwXHhhMicsICMg4oCiCisgICAgICAgIDB4OTYgOiBiJ1x4ZTJceDgwXHg5MycsICMg4oCTCisgICAgICAgIDB4OTcgOiBiJ1x4ZTJceDgwXHg5NCcsICMg4oCUCisgICAgICAgIDB4OTggOiBiJ1x4Y2JceDljJywgICAgICMgy5wKKyAgICAgICAgMHg5OSA6IGInXHhlMlx4ODRceGEyJywgIyDihKIKKyAgICAgICAgMHg5YSA6IGInXHhjNVx4YTEnLCAgICAgIyDFoQorICAgICAgICAweDliIDogYidceGUyXHg4MFx4YmEnLCAjIOKAugorICAgICAgICAweDljIDogYidceGM1XHg5MycsICAgICAjIMWTCisgICAgICAgIDB4OWUgOiBiJ1x4YzVceGJlJywgICAgICMgxb4KKyAgICAgICAgMHg5ZiA6IGInXHhjNVx4YjgnLCAgICAgIyDFuAorICAgICAgICAweGEwIDogYidceGMyXHhhMCcsICAgICAjIMKgCisgICAgICAgIDB4YTEgOiBiJ1x4YzJceGExJywgICAgICMgwqEKKyAgICAgICAgMHhhMiA6IGInXHhjMlx4YTInLCAgICAgIyDCogorICAgICAgICAweGEzIDogYidceGMyXHhhMycsICAgICAjIMKjCisgICAgICAgIDB4YTQgOiBiJ1x4YzJceGE0JywgICAgICMgwqQKKyAgICAgICAgMHhhNSA6IGInXHhjMlx4YTUnLCAgICAgIyDCpQorICAgICAgICAweGE2IDogYidceGMyXHhhNicsICAgICAjIMKmCisgICAgICAgIDB4YTcgOiBiJ1x4YzJceGE3JywgICAgICMgwqcKKyAgICAgICAgMHhhOCA6IGInXHhjMlx4YTgnLCAgICAgIyDCqAorICAgICAgICAweGE5IDogYidceGMyXHhhOScsICAgICAjIMKpCisgICAgICAgIDB4YWEgOiBiJ1x4YzJceGFhJywgICAgICMgwqoKKyAgICAgICAgMHhhYiA6IGInXHhjMlx4YWInLCAgICAgIyDCqworICAgICAgICAweGFjIDogYidceGMyXHhhYycsICAgICAjIMKsCisgICAgICAgIDB4YWQgOiBiJ1x4YzJceGFkJywgICAgICMgwq0KKyAgICAgICAgMHhhZSA6IGInXHhjMlx4YWUnLCAgICAgIyDCrgorICAgICAgICAweGFmIDogYidceGMyXHhhZicsICAgICAjIMKvCisgICAgICAgIDB4YjAgOiBiJ1x4YzJceGIwJywgICAgICMgwrAKKyAgICAgICAgMHhiMSA6IGInXHhjMlx4YjEnLCAgICAgIyDCsQorICAgICAgICAweGIyIDogYidceGMyXHhiMicsICAgICAjIMKyCisgICAgICAgIDB4YjMgOiBiJ1x4YzJceGIzJywgICAgICMgwrMKKyAgICAgICAgMHhiNCA6IGInXHhjMlx4YjQnLCAgICAgIyDCtAorICAgICAgICAweGI1IDogYidceGMyXHhiNScsICAgICAjIMK1CisgICAgICAgIDB4YjYgOiBiJ1x4YzJceGI2JywgICAgICMgwrYKKyAgICAgICAgMHhiNyA6IGInXHhjMlx4YjcnLCAgICAgIyDCtworICAgICAgICAweGI4IDogYidceGMyXHhiOCcsICAgICAjIMK4CisgICAgICAgIDB4YjkgOiBiJ1x4YzJceGI5JywgICAgICMgwrkKKyAgICAgICAgMHhiYSA6IGInXHhjMlx4YmEnLCAgICAgIyDCugorICAgICAgICAweGJiIDogYidceGMyXHhiYicsICAgICAjIMK7CisgICAgICAgIDB4YmMgOiBiJ1x4YzJceGJjJywgICAgICMgwrwKKyAgICAgICAgMHhiZCA6IGInXHhjMlx4YmQnLCAgICAgIyDCvQorICAgICAgICAweGJlIDogYidceGMyXHhiZScsICAgICAjIMK+CisgICAgICAgIDB4YmYgOiBiJ1x4YzJceGJmJywgICAgICMgwr8KKyAgICAgICAgMHhjMCA6IGInXHhjM1x4ODAnLCAgICAgIyDDgAorICAgICAgICAweGMxIDogYidceGMzXHg4MScsICAgICAjIMOBCisgICAgICAgIDB4YzIgOiBiJ1x4YzNceDgyJywgICAgICMgw4IKKyAgICAgICAgMHhjMyA6IGInXHhjM1x4ODMnLCAgICAgIyDDgworICAgICAgICAweGM0IDogYidceGMzXHg4NCcsICAgICAjIMOECisgICAgICAgIDB4YzUgOiBiJ1x4YzNceDg1JywgICAgICMgw4UKKyAgICAgICAgMHhjNiA6IGInXHhjM1x4ODYnLCAgICAgIyDDhgorICAgICAgICAweGM3IDogYidceGMzXHg4NycsICAgICAjIMOHCisgICAgICAgIDB4YzggOiBiJ1x4YzNceDg4JywgICAgICMgw4gKKyAgICAgICAgMHhjOSA6IGInXHhjM1x4ODknLCAgICAgIyDDiQorICAgICAgICAweGNhIDogYidceGMzXHg4YScsICAgICAjIMOKCisgICAgICAgIDB4Y2IgOiBiJ1x4YzNceDhiJywgICAgICMgw4sKKyAgICAgICAgMHhjYyA6IGInXHhjM1x4OGMnLCAgICAgIyDDjAorICAgICAgICAweGNkIDogYidceGMzXHg4ZCcsICAgICAjIMONCisgICAgICAgIDB4Y2UgOiBiJ1x4YzNceDhlJywgICAgICMgw44KKyAgICAgICAgMHhjZiA6IGInXHhjM1x4OGYnLCAgICAgIyDDjworICAgICAgICAweGQwIDogYidceGMzXHg5MCcsICAgICAjIMOQCisgICAgICAgIDB4ZDEgOiBiJ1x4YzNceDkxJywgICAgICMgw5EKKyAgICAgICAgMHhkMiA6IGInXHhjM1x4OTInLCAgICAgIyDDkgorICAgICAgICAweGQzIDogYidceGMzXHg5MycsICAgICAjIMOTCisgICAgICAgIDB4ZDQgOiBiJ1x4YzNceDk0JywgICAgICMgw5QKKyAgICAgICAgMHhkNSA6IGInXHhjM1x4OTUnLCAgICAgIyDDlQorICAgICAgICAweGQ2IDogYidceGMzXHg5NicsICAgICAjIMOWCisgICAgICAgIDB4ZDcgOiBiJ1x4YzNceDk3JywgICAgICMgw5cKKyAgICAgICAgMHhkOCA6IGInXHhjM1x4OTgnLCAgICAgIyDDmAorICAgICAgICAweGQ5IDogYidceGMzXHg5OScsICAgICAjIMOZCisgICAgICAgIDB4ZGEgOiBiJ1x4YzNceDlhJywgICAgICMgw5oKKyAgICAgICAgMHhkYiA6IGInXHhjM1x4OWInLCAgICAgIyDDmworICAgICAgICAweGRjIDogYidceGMzXHg5YycsICAgICAjIMOcCisgICAgICAgIDB4ZGQgOiBiJ1x4YzNceDlkJywgICAgICMgw50KKyAgICAgICAgMHhkZSA6IGInXHhjM1x4OWUnLCAgICAgIyDDngorICAgICAgICAweGRmIDogYidceGMzXHg5ZicsICAgICAjIMOfCisgICAgICAgIDB4ZTAgOiBiJ1x4YzNceGEwJywgICAgICMgw6AKKyAgICAgICAgMHhlMSA6IGInXHhhMScsICAgICAjIMOhCisgICAgICAgIDB4ZTIgOiBiJ1x4YzNceGEyJywgICAgICMgw6IKKyAgICAgICAgMHhlMyA6IGInXHhjM1x4YTMnLCAgICAgIyDDoworICAgICAgICAweGU0IDogYidceGMzXHhhNCcsICAgICAjIMOkCisgICAgICAgIDB4ZTUgOiBiJ1x4YzNceGE1JywgICAgICMgw6UKKyAgICAgICAgMHhlNiA6IGInXHhjM1x4YTYnLCAgICAgIyDDpgorICAgICAgICAweGU3IDogYidceGMzXHhhNycsICAgICAjIMOnCisgICAgICAgIDB4ZTggOiBiJ1x4YzNceGE4JywgICAgICMgw6gKKyAgICAgICAgMHhlOSA6IGInXHhjM1x4YTknLCAgICAgIyDDqQorICAgICAgICAweGVhIDogYidceGMzXHhhYScsICAgICAjIMOqCisgICAgICAgIDB4ZWIgOiBiJ1x4YzNceGFiJywgICAgICMgw6sKKyAgICAgICAgMHhlYyA6IGInXHhjM1x4YWMnLCAgICAgIyDDrAorICAgICAgICAweGVkIDogYidceGMzXHhhZCcsICAgICAjIMOtCisgICAgICAgIDB4ZWUgOiBiJ1x4YzNceGFlJywgICAgICMgw64KKyAgICAgICAgMHhlZiA6IGInXHhjM1x4YWYnLCAgICAgIyDDrworICAgICAgICAweGYwIDogYidceGMzXHhiMCcsICAgICAjIMOwCisgICAgICAgIDB4ZjEgOiBiJ1x4YzNceGIxJywgICAgICMgw7EKKyAgICAgICAgMHhmMiA6IGInXHhjM1x4YjInLCAgICAgIyDDsgorICAgICAgICAweGYzIDogYidceGMzXHhiMycsICAgICAjIMOzCisgICAgICAgIDB4ZjQgOiBiJ1x4YzNceGI0JywgICAgICMgw7QKKyAgICAgICAgMHhmNSA6IGInXHhjM1x4YjUnLCAgICAgIyDDtQorICAgICAgICAweGY2IDogYidceGMzXHhiNicsICAgICAjIMO2CisgICAgICAgIDB4ZjcgOiBiJ1x4YzNceGI3JywgICAgICMgw7cKKyAgICAgICAgMHhmOCA6IGInXHhjM1x4YjgnLCAgICAgIyDDuAorICAgICAgICAweGY5IDogYidceGMzXHhiOScsICAgICAjIMO5CisgICAgICAgIDB4ZmEgOiBiJ1x4YzNceGJhJywgICAgICMgw7oKKyAgICAgICAgMHhmYiA6IGInXHhjM1x4YmInLCAgICAgIyDDuworICAgICAgICAweGZjIDogYidceGMzXHhiYycsICAgICAjIMO8CisgICAgICAgIDB4ZmQgOiBiJ1x4YzNceGJkJywgICAgICMgw70KKyAgICAgICAgMHhmZSA6IGInXHhjM1x4YmUnLCAgICAgIyDDvgorICAgICAgICB9CisKKyAgICBNVUxUSUJZVEVfTUFSS0VSU19BTkRfU0laRVMgPSBbCisgICAgICAgICgweGMyLCAweGRmLCAyKSwgIyAyLWJ5dGUgY2hhcmFjdGVycyBzdGFydCB3aXRoIGEgYnl0ZSBDMi1ERgorICAgICAgICAoMHhlMCwgMHhlZiwgMyksICMgMy1ieXRlIGNoYXJhY3RlcnMgc3RhcnQgd2l0aCBFMC1FRgorICAgICAgICAoMHhmMCwgMHhmNCwgNCksICMgNC1ieXRlIGNoYXJhY3RlcnMgc3RhcnQgd2l0aCBGMC1GNAorICAgICAgICBdCisKKyAgICBGSVJTVF9NVUxUSUJZVEVfTUFSS0VSID0gTVVMVElCWVRFX01BUktFUlNfQU5EX1NJWkVTWzBdWzBdCisgICAgTEFTVF9NVUxUSUJZVEVfTUFSS0VSID0gTVVMVElCWVRFX01BUktFUlNfQU5EX1NJWkVTWy0xXVsxXQorCisgICAgQGNsYXNzbWV0aG9kCisgICAgZGVmIGRldHdpbmdsZShjbHMsIGluX2J5dGVz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ICAgICAgIGlmIG1haW5fZW5jb2RpbmcubG93ZXIoKSBub3QgaW4gKCd1dGY4JywgJ3V0Zi04Jyk6CisgICAgICAgICAgICByYWlzZSBOb3RJbXBsZW1lbnRlZEVycm9yKAorICAgICAgICAgICAgICAgICJVVEYtOCBpcyB0aGUgb25seSBjdXJyZW50bHkgc3VwcG9ydGVkIG1haW4gZW5jb2RpbmcuIikKKworICAgICAgICBieXRlX2NodW5rcyA9IFtdCisKKyAgICAgICAgY2h1bmtfc3RhcnQgPSAwCisgICAgICAgIHBvcyA9IDAKKyAgICAgICAgd2hpbGUgcG9zIDwgbGVuKGluX2J5dGVzKToKKyAgICAgICAgICAgIGJ5dGUgPSBpbl9ieXRlc1twb3NdCisgICAgICAgICAgICBpZiBub3QgaXNpbnN0YW5jZShieXRlLCBpbnQpOgorICAgICAgICAgICAgICAgICMgUHl0aG9uIDIueAorICAgICAgICAgICAgICAgIGJ5dGUgPSBvcmQoYnl0ZSkKKyAgICAgICAgICAgIGlmIChieXRlID49IGNscy5GSVJTVF9NVUxUSUJZVEVfTUFSS0VSCisgICAgICAgICAgICAgICAgYW5kIGJ5dGUgPD0gY2xzLkxBU1RfTVVMVElCWVRFX01BUktFUik6CisgICAgICAgICAgICAgICAgIyBUaGlzIGlzIHRoZSBzdGFydCBvZiBhIFVURi04IG11bHRpYnl0ZSBjaGFyYWN0ZXIuIFNraXAKKyAgICAgICAgICAgICAgICAjIHRvIHRoZSBlbmQuCisgICAgICAgICAgICAgICAgZm9yIHN0YXJ0LCBlbmQsIHNpemUgaW4gY2xzLk1VTFRJQllURV9NQVJLRVJTX0FORF9TSVpFUzoKKyAgICAgICAgICAgICAgICAgICAgaWYgYnl0ZSA+PSBzdGFydCBhbmQgYnl0ZSA8PSBlbmQ6CisgICAgICAgICAgICAgICAgICAgICAgICBwb3MgKz0gc2l6ZQorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWsKKyAgICAgICAgICAgIGVsaWYgYnl0ZSA+PSAweDgwIGFuZCBieXRlIGluIGNscy5XSU5ET1dTXzEyNTJfVE9fVVRGODoKKyAgICAgICAgICAgICAgICAjIFdlIGZvdW5kIGEgV2luZG93cy0xMjUyIGNoYXJhY3RlciEKKyAgICAgICAgICAgICAgICAjIFNhdmUgdGhlIHN0cmluZyB1cCB0byB0aGlzIHBvaW50IGFzIGEgY2h1bmsuCisgICAgICAgICAgICAgICAgYnl0ZV9jaHVua3MuYXBwZW5kKGluX2J5dGVzW2NodW5rX3N0YXJ0OnBvc10pCisKKyAgICAgICAgICAgICAgICAjIE5vdyB0cmFuc2xhdGUgdGhlIFdpbmRvd3MtMTI1MiBjaGFyYWN0ZXIgaW50byBVVEYtOAorICAgICAgICAgICAgICAgICMgYW5kIGFkZCBpdCBhcyBhbm90aGVyLCBvbmUtYnl0ZSBjaHVuay4KKyAgICAgICAgICAgICAgICBieXRlX2NodW5rcy5hcHBlbmQoY2xzLldJTkRPV1NfMTI1Ml9UT19VVEY4W2J5dGVdKQorICAgICAgICAgICAgICAgIHBvcyArPSAxCisgICAgICAgICAgICAgICAgY2h1bmtfc3RhcnQgPSBwb3MKKyAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAgICAgICAgIyBHbyBvbiB0byB0aGUgbmV4dCBjaGFyYWN0ZXIuCisgICAgICAgICAgICAgICAgcG9zICs9IDEKKyAgICAgICAgaWYgY2h1bmtfc3RhcnQgPT0gMDoKKyAgICAgICAgICAgICMgVGhlIHN0cmluZyBpcyB1bmNoYW5nZWQuCisgICAgICAgICAgICByZXR1cm4gaW5fYnl0ZXMKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgICMgU3RvcmUgdGhlIGZpbmFsIGNodW5rLgorICAgICAgICAgICAgYnl0ZV9jaHVua3MuYXBwZW5kKGluX2J5dGVzW2NodW5rX3N0YXJ0Ol0pCisgICAgICAgIHJldHVybiBiJycuam9pbihieXRlX2NodW5rcykKKwpkaWZmIC0tZ2l0IGEvYml0YmFrZS9saWIvYnM0L2RpYWdub3NlL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luIGJ1aWxkZXJfcmVnaXN0cnkuYnVpbGRlcnM6CisgICAgICAgICAgICBpZiBuYW1lIGluIGJ1aWxkZXIuZmVhdHVyZXM6CisgICAgICAgICAgICAgICAgYnJlYWsKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIGJhc2ljX3BhcnNlcnMucmVtb3ZlKG5hbWUpCisgICAgICAgICAgICBwcmludCAoCisgICAgICAgICAgICAgICAgIkkgbm90aWNlZCB0aGF0ICVzIGlzIG5vdCBpbnN0YWxsZWQuIEluc3RhbGxpbmcgaXQgbWF5IGhlbHAuIiAlCisgICAgICAgICAgICAgICAgbmFtZSkKKworICAgIGlmICdseG1sJyBpbiBiYXNpY19wYXJzZXJzOgorICAgICAgICBiYXNpY19wYXJzZXJzLmFwcGVuZChbImx4bWwiLCAieG1sIl0pCisgICAgICAgIGZyb20gbHhtbCBpbXBvcnQgZXRyZWUKKyAgICAgICAgcHJpbnQgIkZvdW5kIGx4bWwgdmVyc2lvbiAlcyIgJSAiLiIuam9pbihtYXAoc3RyLGV0cmVlLkxYTUxfVkVSU0lPTikpCisKKyAgICBpZiAnaHRtbDVsaWInIGluIGJhc2ljX3BhcnNlcnM6CisgICAgICAgIGltcG9ydCBodG1sNWxpYgorICAgICAgICBwcmludCAiRm91bmQgaHRtbDVsaWIgdmVyc2lvbiAlcyIgJSBodG1sNWxpYi5fX3ZlcnNpb25fXworCisgICAgaWYgaGFzYXR0cihkYXRhLCAncmVhZCcpOgorICAgICAgICBkYXRhID0gZGF0YS5yZWFkKCkKKyAgICBlbGlmIG9zLnBhdGguZXhpc3RzKGRhdGEpOgorICAgICAgICBwcmludCAnIiVzIiBsb29rcyBsaWtlIGEgZmlsZW5hbWUuIFJlYWRpbmcgZGF0YSBmcm9tIHRoZSBmaWxlLicgJSBkYXRhCisgICAgICAgIGRhdGEgPSBvcGVuKGRhdGEpLnJlYWQoKQorICAgIGVsaWYgZGF0YS5zdGFydHN3aXRoKCJodHRwOiIpIG9yIGRhdGEu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ICJcbiIuam9pbihlbGVtZW50cykgKyAiPC9odG1sPiIKKworZGVmIGJlbmNobWFya19wYXJzZXJzKG51bV9lbGVtZW50cz0xMDAwMDApOgorICAgICIiIlZlcnkgYmFzaWMgaGVhZC10by1oZWFkIHBlcmZvcm1hbmNlIGJlbmNobWFyay4iIiIKKyAgICBwcmludCAiQ29tcGFyYXRpdmUgcGFyc2VyIGJlbmNobWFyayBvbiBCZWF1dGlmdWwgU291cCAlcyIgJSBfX3ZlcnNpb25fXworICAgIGRhdGEgPSByZG9jKG51bV9lbGVtZW50cykKKyAgICBwcmludCAiR2VuZXJhdGVkIGEgbGFyZ2UgaW52YWxpZCBIVE1MIGRvY3VtZW50ICglZCBieXRlcykuIiAlIGxlbihkYXRhKQorICAgIAorICAgIGZvciBwYXJzZXIgaW4gWyJseG1sIiwgWyJseG1sIiwgImh0bWwiXSwgImh0bWw1bGliIiwgImh0bWwucGFyc2VyIl06CisgICAgICAgIHN1Y2Nlc3MgPSBGYWxzZQorICAgICAgICB0cnk6CisgICAgICAgICAgICBhID0gdGltZS50aW1lKCkKKyAgICAgICAgICAgIHNvdXAgPSBCZWF1dGlmdWxTb3VwKGRhdGEsIHBhcnNlcikKKyAgICAgICAgICAgIGIgPSB0aW1lLnRpbWUoKQorICAgICAgICAgICAgc3VjY2VzcyA9IFRydWUKKyAgICAgICAgZXhjZXB0IEV4Y2VwdGlvbiwgZToKKyAgICAgICAgICAgIHByaW50ICIlcyBjb3VsZCBub3QgcGFyc2UgdGhlIG1hcmt1cC4iICUgcGFyc2VyCisgICAgICAgICAgICB0cmFjZWJhY2sucHJpbnRfZXhjKCkKKyAgICAgICAgaWYgc3VjY2VzczoKKyAgICAgICAgICAgIHByaW50ICJCUzQrJXMgcGFyc2VkIHRoZSBtYXJrdXAgaW4gJS4yZnMuIiAlIChwYXJzZXIsIGItYSkKKworICAgIGZyb20gbHhtbCBpbXBvcnQgZXRyZWUKKyAgICBhID0gdGltZS50aW1lKCkKKyAgICBldHJlZ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AgICAgICBvdGhlciBlbGVtZW50cy4iIiIKKyAgICAgICAgc2VsZi5wYXJlbnQgPSBwYXJlbnQKKyAgICAgICAgc2VsZi5wcmV2aW91c19lbGVtZW50ID0gcHJldmlvdXNfZWxlbWVudAorICAgICAgICBpZiBwcmV2aW91c19lbGVtZW50IGlzIG5vdCBOb25lOgorICAgICAgICAgICAgc2VsZi5wcmV2aW91c19lbGVtZW50Lm5leHRfZWxlbWVudCA9IHNlbGYKKyAgICAgICAgc2VsZi5uZXh0X2VsZW1lbnQgPSBOb25lCisgICAgICAgIHNlbGYucHJldmlvdXNfc2libGluZyA9IE5vbmUKKyAgICAgICAgc2VsZi5uZXh0X3NpYmxpbmcgPSBOb25lCisgICAgICAgIGlmIHNlbGYucGFyZW50IGlzIG5vdCBOb25lIGFuZCBzZWxmLnBhcmVudC5jb250ZW50czoKKyAgICAgICAgICAgIHNlbGYucHJldmlvdXNfc2libGluZyA9IHNlbGYucGFyZW50LmNvbnRlbnRzWy0xXQorICAgICAgICAgICAgc2VsZi5wcmV2aW91c19zaWJsaW5nLm5leHRfc2libGluZyA9IHNlbGYKKworICAgIG5leHRTaWJsaW5nID0gX2FsaWFzKCJuZXh0X3NpYmxpbmciKSAgIyBCUzMKKyAgICBwcmV2aW91c1NpYmxpbmcgPSBfYWxpYXMoInByZXZpb3VzX3NpYmxpbmciKSAgIyBCUzMKKworICAgIGRlZiByZXBsYWNlX3dpdGgoc2VsZiwgcmVwbGFjZV93aXRoKToKKyAgICAgICAgaWYgcmVwbGFjZV93aXRoIGlzIHNlbGY6CisgICAgICAgICAgICByZXR1cm4KKyAgICAgICAgaWYgcmVwbGFjZV93aXRoIGlzIHNlbGYucGFyZW50OgorICAgICAgICAgICAgcmFpc2UgVmFsdWVFcnJvcigiQ2Fubm90IHJlcGxhY2UgYSBUYWcgd2l0aCBpdHMgcGFyZW50LiIpCisgICAgICAgIG9sZF9wYXJlbnQgPSBzZWxmLnBhcmVudAorICAgICAgICBteV9pbmRleCA9IHNlbGYucGFyZW50LmluZGV4KHNlbGYpCisgICAgICAgIHNlbGYuZXh0cmFjdCgpCisgICAgICAgIG9sZF9wYXJlbnQuaW5zZXJ0KG15X2luZGV4LCByZXBsYWNlX3dpdGgpCisgICAgICAgIHJldHVybiBzZWxmCisgICAgcmVwbGFjZVdpdGggPSByZXBsYWNlX3dpdGggICMgQlMzCisKKyAgICBkZWYgdW53cmFwKHNlbGYpOgorICAgICAgICBteV9wYXJlbnQgPSBzZWxmLnBhcmVudAorICAgICAgICBteV9pbmRleCA9IHNlbGYucGFyZW50LmluZGV4KHNlbGYpCisgICAgICAgIHNlbGYuZXh0cmFjdCgpCisgICAgICAgIGZvciBjaGlsZCBpbiByZXZlcnNlZChzZWxmLmNvbnRlbnRzWzpdKToKKyAgICAgICAgICAgIG15X3BhcmVudC5pbnNlcnQobXlfaW5kZXgsIGNoaWxkKQorICAgICAgICByZXR1cm4gc2VsZgorICAgIHJlcGxhY2Vfd2l0aF9jaGlsZHJlbiA9IHVud3JhcAorICAgIHJlcGxhY2VXaXRoQ2hpbGRyZW4gPSB1bndyYXAgICMgQlMzCisKKyAgICBkZWYgd3JhcChzZWxmLCB3cmFwX2luc2lkZSk6CisgICAgICAgIG1lID0gc2VsZi5yZXBsYWNlX3dpdGgod3JhcF9pbnNpZGUpCisgICAgICAgIHdyYXBfaW5zaWRlLmFwcGVuZChtZSkKKyAgICAgICAgcmV0dXJuIHdyYXBfaW5zaWRlCisKKyAgICBkZWYgZXh0cmFjdChzZWxmKToKKyAgICAgICAgIiIiRGVzdHJ1Y3RpdmVseSByaXBzIHRoaXMgZWxlbWVudCBvdXQgb2YgdGhlIHRyZWUuIiIiCisgICAgICAgIGlmIHNlbGYucGFyZW50IGlzIG5vdCBOb25lOgorICAgICAgICAgICAgZGVsIHNlbGYucGFyZW50LmNvbnRlbnRzW3NlbGYucGFyZW50LmluZGV4KHNlbGYpXQorCisgICAgICAgICNGaW5kIHRoZSB0d28gZWxlbWVudHMgdGhhdCB3b3VsZCBiZSBuZXh0IHRvIGVhY2ggb3RoZXIgaWYKKyAgICAgICAgI3RoaXMgZWxlbWVudCAoYW5kIGFueSBjaGlsZHJlbikgaGFkbid0IGJlZW4gcGFyc2VkLiBDb25uZWN0CisgICAgICAgICN0aGUgdHdvLgorICAgICAgICBsYXN0X2NoaWxkID0gc2VsZi5fbGFzdF9kZXNjZW5kYW50KCkKKyAgICAgICAgbmV4dF9lbGVtZW50ID0gbGFzdF9jaGlsZC5uZXh0X2VsZW1lbnQKKworICAgICAgICBpZiBzZWxmLnByZXZpb3VzX2VsZW1lbnQgaXMgbm90IE5vbmU6CisgICAgICAgICAgICBzZWxmLnByZXZpb3VzX2VsZW1lbnQubmV4dF9lbGVtZW50ID0gbmV4dF9lbGVtZW50CisgICAgICAgIGlmIG5leHRfZWxlbWVudCBpcyBub3QgTm9uZToKKyAgICAgICAgICAgIG5leHRfZWxlbWVudC5wcmV2aW91c19lbGVtZW50ID0gc2VsZi5wcmV2aW91c19lbGVtZW50CisgICAgICAgIHNlbGYucHJldmlvdXNfZWxlbWVudCA9IE5vbmUKKyAgICAgICAgbGFzdF9jaGlsZC5uZXh0X2VsZW1lbnQgPSBOb25lCisKKyAgICAgICAgc2VsZi5wYXJlbnQgPSBOb25lCisgICAgICAgIGlmIHNlbGYucHJldmlvdXNfc2libGluZyBpcyBub3QgTm9uZToKKyAgICAgICAgICAgIHNlbGYucHJldmlvdXNfc2libGluZy5uZXh0X3NpYmxpbmcgPSBzZWxmLm5leHRfc2libGluZworICAgICAgICBpZiBzZWxmLm5leHRfc2libGluZyBpcyBub3QgTm9uZToKKyAgICAgICAgICAgIHNlbGYubmV4dF9zaWJsaW5nLnByZXZpb3VzX3NpYmxpbmcgPSBzZWxmLnByZXZpb3VzX3NpYmxpbmcKKyAgICAgICAgc2VsZi5wcmV2aW91c19zaWJsaW5nID0gc2VsZi5uZXh0X3NpYmxpbmcgPSBOb25lCisgICAgICAgIHJldHVybiBzZWxmCisKKyAgICBkZWY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WdhYmxlU3RyaW5nKSk6CisgICAgICAgICAgICBuZXdfY2hpbGQgPSBOYXZpZ2FibGVTdHJpbmcobmV3X2NoaWxkKQorCisgICAgICAgIHBvc2l0aW9uID0gbWluKHBvc2l0aW9uLCBsZW4oc2VsZi5jb250ZW50cykpCisgICAgICAgIGlmIGhhc2F0dHIobmV3X2NoaWxkLCAncGFyZW50JykgYW5kIG5ld19jaGlsZC5wYXJlbnQgaXMgbm90IE5vbmU6CisgICAgICAgICAgICAjIFdlJ3JlICdpbnNlcnRpbmcnIGFuIGVsZW1lbnQgdGhhdCdzIGFscmVhZHkgb25lCisgICAgICAgICAgICAjIG9mIHRoaXMgb2JqZWN0J3MgY2hpbGRyZW4uCisgICAgICAgICAgICBpZiBuZXdfY2hpbGQucGFyZW50IGlzIHNlbGY6CisgICAgICAgICAgICAgICAgY3VycmVudF9pbmRleCA9IHNlbGYuaW5kZXgobmV3X2NoaWxkKQorICAgICAgICAgICAgICAgIGlmIGN1cnJlbnRfaW5kZXggPCBwb3NpdGlvbjoKKyAgICAgICAgICAgICAgICAgICAgIyBXZSdyZSBtb3ZpbmcgdGhpcyBlbGVtZW50IGZ1cnRoZXIgZG93biB0aGUgbGlzdAorICAgICAgICAgICAgICAgICAgICAjIG9mIHRoaXMgb2JqZWN0J3MgY2hpbGRyZW4uIFRoYXQgbWVhbnMgdGhhdCB3aGVuCisgICAgICAgICAgICAgICAgICAgICMgd2UgZXh0cmFjdCB0aGlzIGVsZW1lbnQsIG91ciB0YXJnZXQgaW5kZXggd2lsbAorICAgICAgICAgICAgICAgICAgICAjIGp1bXAgZG93biBvbmUuCisgICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uIC09IDEKKyAgICAgICAgICAgIG5ld19jaGlsZC5leHRyYWN0KCkKKworICAgICAgICBuZXdfY2hpbGQucGFyZW50ID0gc2VsZgorICAgICAgICBwcmV2aW91c19jaGlsZCA9IE5vbmUKKyAgICAgICAgaWYgcG9zaXRpb24gPT0gMDoKKyAgICAgICAgICAgIG5ld19jaGlsZC5wcmV2aW91c19zaWJsaW5nID0gTm9uZQorICAgICAgICAgICAgbmV3X2NoaWxkLnByZXZpb3VzX2VsZW1lbnQgPSBzZWxmCisgICAgICAgIGVsc2U6CisgICAgICAgICAgICBwcmV2aW91c19jaGlsZCA9IHNlbGYuY29udGVudHNbcG9zaXRpb24gLSAxXQorICAgICAgICAgICAgbmV3X2NoaWxkLnByZXZpb3VzX3NpYmxpbmcgPSBwcmV2aW91c19jaGlsZAorICAgICAgICAgICAgbmV3X2NoaWxkLnByZXZpb3VzX3NpYmxpbmcubmV4dF9zaWJsaW5nID0gbmV3X2NoaWxkCisgICAgICAgICAgICBuZXdfY2hpbGQucHJldmlvdXNfZWxlbWVudCA9IHByZXZpb3VzX2NoaWxkLl9sYXN0X2Rlc2NlbmRhbnQoRmFsc2UpCisgICAgICAgIGlmIG5ld19jaGlsZC5wcmV2aW91c19lbGVtZW50IGlzIG5vdCBOb25lOgorICAgICAgICAgICAgbmV3X2NoaWxkLnByZXZpb3VzX2VsZW1lbnQubmV4dF9lbGVtZW50ID0gbmV3X2NoaWxkCisKKyAgICAgICAgbmV3X2NoaWxkc19sYXN0X2VsZW1lbnQgPSBuZXdfY2hpbGQuX2xhc3RfZGVzY2VuZGFudChGYWxzZSkKKworICAgICAgICBpZiBwb3NpdGlvbiA+PSBsZW4oc2VsZi5jb250ZW50cyk6CisgICAgICAgICAgICBuZXdfY2hpbGQubmV4dF9zaWJsaW5nID0gTm9uZQorCisgICAgICAgICAgICBwYXJlbnQgPSBzZWxmCisgICAgICAgICAgICBwYXJlbnRzX25leHRfc2libGluZyA9IE5vbmUKKyAgICAgICAgICAgIHdoaWxlIHBhcmVudHNfbmV4dF9zaWJsaW5nIGlzIE5vbmUgYW5kIHBhcmVudCBpcyBub3QgTm9uZToKKyAgICAgICAgICAgICAgICBwYXJlbnRzX25leHRfc2libGluZyA9IHBhcmVudC5uZXh0X3NpYmxpbmcKKyAgICAgICAgICAgICAgICBwYXJlbnQgPSBwYXJlbnQucGFyZW50CisgICAgICAgICAgICAgICAgaWYgcGFyZW50c19uZXh0X3NpYmxpbmcgaXMgbm90IE5vbmU6CisgICAgICAgICAgICAgICAgICAgICMgV2UgZm91bmQgdGhlIGVsZW1lbnQgdGhhdCBjb21lcyBuZXh0IGluIHRoZSBkb2N1bWVudC4KKyAgICAgICAgICAgICAgICAgICAgYnJlYWsKKyAgICAgICAgICAgIGlmIHBhcmVudHNfbmV4dF9zaWJsaW5nIGlzIG5vdCBOb25lOgorICAgICAgICAgICAgICAgIG5ld19jaGlsZHNfbGFzdF9lbGVtZW50Lm5leHRfZWxlbWVudCA9IHBhcmVudHNfbmV4dF9zaWJsaW5nCisgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgICMgVGhlIGxhc3QgZWxlbWVudCBvZiB0aGlzIHRhZyBpcyB0aGUgbGFzdCBlbGVtZW50IGluCisgICAgICAgICAgICAgICAgIyB0aGUgZG9jdW1lbnQuCisgICAgICAgICAgICAgICAgbmV3X2NoaWxkc19sYXN0X2VsZW1lbnQubmV4dF9lbGVtZW50ID0gTm9uZQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgbmV4dF9jaGlsZCA9IHNlbGYuY29udGVudHNbcG9zaXRpb25dCisgICAgICAgICAgICBuZXdfY2hpbGQubmV4dF9zaWJsaW5nID0gbmV4dF9jaGlsZAorICAgICAgICAgICAgaWYgbmV3X2NoaWxkLm5leHRfc2libGluZyBpcyBub3QgTm9uZToKKyAgICAgICAgICAgICAgICBuZXdfY2hpbGQubmV4dF9zaWJsaW5nLnByZXZpb3VzX3NpYmxpbmcgPSBuZXdfY2hpbGQKKyAgICAgICAgICAgIG5ld19jaGlsZHNfbGFzdF9lbGVtZW50Lm5leHRfZWxlbWVudCA9IG5leHRfY2hpbGQKKworICAgICAgICBpZiBuZXdfY2hpbGRzX2xhc3RfZWxlbWVudC5uZXh0X2VsZW1lbnQgaXMgbm90IE5vbmU6CisgICAgICAgICAgIC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3BlcnR5CisgICAgZGVmIG5leHQoc2VsZik6CisgICAgICAgIHJldHVybiBzZWxmLm5leHRfZWxlbWVudAorCisgICAgQHByb3BlcnR5CisgICAgZGVmIHByZXZpb3VzKHNlbGYpOgorICAgICAgICByZXR1cm4gc2VsZi5wcmV2aW91c19lbGVtZW50CisKKyAgICAjVGhlc2UgbWV0aG9kcyBkbyB0aGUgcmVhbCBoZWF2eSBsaWZ0aW5nLgorCisgICAgZGVmIF9maW5kX29uZShzZWxmLCBtZXRob2QsIG5hbWUsIGF0dHJzLCB0ZXh0LCAqKmt3YXJncyk6CisgICAgICAgIHIgPSBOb25lCisgICAgICAgIGwgPSBtZXRob2QobmFtZSwgYXR0cnMsIHRleHQsIDEsICoqa3dhcmdzKQorICAgICAgICBpZiBsOgorICAgICAgICAgICAgciA9IGxbMF0KKyAgICAgICAgcmV0dXJuIHIKKworICAgIGRlZiBfZmluZF9hbGwoc2VsZiwgbmFtZSwgYXR0cnMsIHRleHQsIGxpbWl0LCBnZW5lcmF0b3IsICoqa3dhcmdzKToKKyAgICAgICAgIkl0ZXJhdGVzIG92ZXIgYSBnZW5lcmF0b3IgbG9va2luZyBmb3IgdGhpbmdzIHRoYXQgbWF0Y2guIgorCisgICAgICAgIGlmIGlzaW5zdGFuY2UobmFtZSwgU291cFN0cmFpbmVyKToKKyAgICAgICAgICAgIHN0cmFpbmVyID0gbmFtZQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgc3RyYWluZXIgPSBTb3VwU3RyYWluZXIobmFtZSwgYXR0cnMsIHRleHQsICoqa3dhcmdzKQorCisgICAgICAgIGlmIHRleHQgaXMgTm9uZSBhbmQgbm90IGxpbWl0IGFuZCBub3QgYXR0cnMgYW5kIG5vdCBrd2FyZ3M6CisgICAgICAgICAgICBpZiBuYW1lIGlzIFRydWUgb3IgbmFtZSBpcyBOb25lOgorICAgICAgICAgICAgICAgICMgT3B0aW1pemF0aW9uIHRvIGZpbmQgYWxsIHRhZ3MuCisgICAgICAgICAgICAgICAgcmVzdWx0ID0gKGVsZW1lbnQgZm9yIGVsZW1lbnQgaW4gZ2VuZXJhdG9yCisgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIGlzaW5zdGFuY2UoZWxlbWVudCwgVGFnKSkKKyAgICAgICAgICAgICAgICByZXR1cm4gUmVzdWx0U2V0KHN0cmFpbmVyLCByZXN1bHQpCisgICAgICAgICAgICBlbGlmIGlzaW5zdGFuY2UobmFtZSwgYmFzZXN0cmluZyk6CisgICAgICAgICAgICAgICAgIyBPcHRpbWl6YXRpb24gdG8gZmluZCBhbGwgdGFncyB3aXRoIGEgZ2l2ZW4gbmFtZS4KKyAgICAgICAgICAgICAgICByZXN1bHQgPSAoZWxlbWVudCBmb3IgZWxlbWVudCBpbiBnZW5lcmF0b3IKKyAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgaXNpbnN0YW5jZShlbGVtZW50LCBUYWcpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5kIGVsZW1lbnQubmFtZSA9PSBuYW1lKQorICAgICAgICAgICAgICAgIHJldHVybiBSZXN1bHRTZXQoc3RyYWluZXIsIHJlc3VsdCkKKyAgICAgICAgcmVzdWx0cyA9IFJlc3VsdFNldChzdHJhaW5lcikKKyAgICAgICAgd2hpbGUgVHJ1ZToKKyAgICAgICAgICAgIHRyeToKKyAgICAgICAgICAgICAgICBpID0gbmV4dChnZW5lcmF0b3IpCisgICAgICAgICAgICBleGNlcHQgU3RvcEl0ZXJhdGlvbjoKKyAgICAgICAgICAgICAgICBicmVhaworICAgICAgICAgICAgaWYgaToKKyAgICAgICAgICAgICAgICBmb3VuZCA9IHN0cmFpbmVyLnNlYXJjaChpKQorICAgICAgICAgICAgICAgIGlmIGZvdW5kOgorICAgICAgICAgICAgICAgICAgICByZXN1bHRzLmFwcGVuZChmb3VuZCkKKyAgICAgICAgICAgICAgICAgICAgaWYgbGltaXQgYW5kIGxlbihyZXN1bHRzKSA+PSBsaW1pdDoKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrCisgICAgICAgIHJldHVybiByZXN1bHRzCisKKyAgICAjVGhlc2UgZ2VuZXJhdG9ycyBjYW4gYmUgdXNlZCB0byBuYXZpZ2F0ZSBzdGFydGluZyBmcm9tIGJvdGgKKyAgICAjTmF2aWdhYmxlU3RyaW5ncyBhbmQgVGFncy4KKyAgICBAcHJvcGVydHkKKyAgICBkZWYgbmV4dF9lbGVtZW50cyhzZWxmKToKKyAgICAgICAgaSA9IHNlbGYubmV4dF9lbGVtZW50CisgICAgICAgIHdoaWxlIGkgaXMgbm90IE5vbmU6CisgICAgICAgICAgICB5aWVsZCBpCisgICAgICAgICAgICBpID0gaS5uZXh0X2VsZW1lbnQKKworICAgIEBwcm9wZXJ0eQorICAgIGRlZiBuZXh0X3NpYmxpbmdzKHNlbGYpOgorICAgICAgICBpID0gc2VsZi5uZXh0X3NpYmxpbmcKKyAgICAgICAgd2hpbGUgaSBpcyBub3QgTm9uZToKKyAgICAgICAgICAgIHlpZWxkIGkKKyAgICAgICAgICAgIGkgPSBpLm5leHRfc2libGluZworCisgICAgQHByb3BlcnR5CisgICAgZGVmIHByZXZpb3VzX2VsZW1lbnRzKHNlbGYpOgorICAgICAgICBpID0gc2VsZi5wcmV2aW91c19lbGVtZW50CisgICAgICAgIHdoaWxlIGkgaXMgbm90IE5vbmU6CisgICAgICAgICAgICB5aWVsZCBpCisgICAgICAgICAgICBpID0gaS5wcmV2aW91c19lbGVtZW50CisKKyAgICBAcHJvcGVydHkKKyAgICBkZWYgcHJldmlvdXNfc2libGluZ3Moc2VsZik6CisgICAgICAgIGkgPSBzZWxmLnByZXZpb3VzX3NpYmxpbmcKKyAgICAgICAgd2hpbGUgaSBpcyBub3QgTm9uZToKKyAgICAgICAgICAgIHlpZWxkIGkKKyAgICAgICAgICAgIGkgPSBpLnByZXZpb3VzX3NpYmxpbmcKKworICAgIEBwcm9wZXJ0eQorICAgIGRlZiBwYXJlbnRzKHNlbGYpOgorICAgICAgICBpID0gc2VsZi5wYXJlbnQKKyAgICAgICAgd2hpbGUgaSBpcyBub3QgTm9uZToKKyAgICAgICAgICAgIHlpZWxkIGkKKyAgICAgICAgICAgIGkgPSBpLnBhcmVudAorCisgICAgIyBNZXRob2RzIGZvciBzdXBwb3J0aW5nIENTUyBzZWxlY3RvcnMuCisKKyAgICB0YWdfbmFtZV9yZSA9IHJlLmNvbXBpbGUoJ15bYS16MC05XSskJykKKworICAgICMgL14oXHcrKVxbKFx3KykoWz1+XHxcXlwkXCpdPyk9PyI/KFteXF0iXSopIj9cXSQvCisgICAgIyAgIFwtLS0vICBcLS0tL1wtLS0tLS0tLS0tLS0tLyAgICBcLS0tLS0tLS8KKyAgICAjICAgICB8ICAgICAgfCAgICAgICAgIHwgICAgICAgICAgICAgICB8CisgICAgIyAgICAgfCAgICAgIHwgICAgICAgICB8ICAgICAgICAgICBUaGUgdmFsdWUKKyAgICAjICAgICB8ICAgICAgfCAgICB+LHwsXiwkLCogb3IgPQorICAgICMgICAgIHwgICBBdHRyaWJ1dGUKKyAgICAjICAgIFRhZworICAgIGF0dHJpYnNlbGVjdF9yZSA9IHJlLmNvbXBpbGUoCisgICAgICAgIHInXig/UDx0YWc+XHcrKT9cWyg/UDxhdHRyaWJ1dGU+XHcrKSg/UDxvcGVyYXRvcj5bPX5cfFxeXCRcKl0/KScgKworICAgICAgICByJz0/Ij8oP1A8dmFsdWU+W15cXSJdKikiP1xdJCcKKyAgICAgICAgKQorCisgICAgZGVmIF9hdHRyX3ZhbHVlX2FzX3N0cmluZyhzZWxmLCB2YWx1ZSwgZGVmYXVsdD1Ob25lKToKKyAgICAgICAgIiIiRm9yY2UgYW4gYXR0cmlidXRlIHZhbHVlIGludG8gYSBzdHJpbmcgcmVwcmVzZW50YXRpb24uCisKKyAgICAgICAgQSBtdWx0aS12YWx1ZWQgYXR0cmlidXRlIHdpbGwgYmUgY29udmVydGVkIGludG8gYQorICAgICAgICBzcGFjZS1zZXBhcmF0ZWQgc3Rpcm5nL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R5IHZlcnNpb25zIG9mIHRoZSBnZW5lcmF0b3JzLCBmb3IgYmFja3dhcmRzCisgICAgIyBjb21wYXRpYmlsaXR5IHdpdGggQlMzLgorICAgIGRlZiBuZXh0R2VuZXJhdG9yKHNlbGYpOgorICAgICAgICByZXR1cm4gc2VsZi5uZXh0X2VsZW1lbnRzCisKKyAgICBkZWYgbmV4dFNpYmxpbmdHZW5lcmF0b3Ioc2VsZik6CisgICAgICAgIHJldHVybiBzZWxmLm5leHRfc2libGluZ3MKKworICAgIGRlZiBwcmV2aW91c0dlbmVyYXRvcihzZWxmKToKKyAgICAgICAgcmV0dXJuIHNlbGYucHJldmlvdXNfZWxlbWVudHMKKworICAgIGRlZiBwcmV2aW91c1NpYmxpbmdHZW5lcmF0b3Ioc2VsZik6CisgICAgICAgIHJldHVybiBzZWxmLnByZXZpb3VzX3NpYmxpbmdzCisKKyAgICBkZWYgcGFyZW50R2VuZXJhdG9yKHNlbGYpOgorICAgICAgICByZXR1cm4gc2VsZi5wYXJlbnRzCisKKworY2xhc3MgTmF2aWdhYmxlU3RyaW5nKHVuaWNvZGUsIFBhZ2VFbGVtZW50KToKKworICAgIFBSRUZJWCA9ICcnCisgICAgU1VGRklYID0gJycKKworICAgIGRlZiBfX25ld19fKGNscywgdmFsdWUpOgorICAgICAgICAiIiJDcmVhdGUgYSBuZXcgTmF2aWdhYmxlU3RyaW5nLgorCisgICAgICAgIFdoZW4gdW5waWNrbGluZyBhIE5hdmlnYWJsZVN0cmluZywgdGhpcyBtZXRob2QgaXMgY2FsbGVkIHdpdGgKKyAgICAgICAgdGhlIHN0cmluZyBpbiBERUZBVUxUX09VVFBVVF9FTkNPRElORy4gVGhhdCBlbmNvZGluZyBuZWVkcyB0byBiZQorICAgICAgICBwYXNzZWQgaW4gdG8gdGhlIHN1cGVyY2xhc3MncyBfX25ld19fIG9yIHRoZSBzdXBlcmNsYXNzIHdvbid0IGtub3cKKyAgICAgICAgaG93IHRvIGhhbmRsZSBub24tQVNDSUkgY2hhcmFjdGVycy4KKyAgICAgICAgIiIiCisgICAgICAgIGlmIGlzaW5zdGFuY2UodmFsdWUsIHVuaWNvZGUpOgorICAgICAgICAgICAgcmV0dXJuIHVuaWNvZGUuX19uZXdfXyhjbHMsIHZhbHVlKQorICAgICAgICByZXR1cm4gdW5pY29kZS5fX25ld19fKGNscywgdmFsdWUsIERFRkFVTFRfT1VUUFVUX0VOQ09ESU5HKQorCisgICAgZGVmIF9fY29weV9fKHNlbGYpOgorICAgICAgICByZXR1cm4gc2VsZgorCisgICAgZGVmIF9fZ2V0bmV3YXJnc19fKHNlbGYpOgorICAgICAgICByZXR1cm4gKHVuaWNvZGUoc2VsZiksKQorCisgICAgZGVmIF9fZ2V0YXR0cl9fKHNlbGYsIGF0dHIpOgorICAgICAgICAiIiJ0ZXh0LnN0cmluZyBnaXZlcyB5b3UgdGV4dC4gVGhpcyBpcyBmb3IgYmFja3dhcmRzCisgICAgICAgIGNvbXBhdGliaWxpdHkgZm9yIE5hdmlnYWJsZSpTdHJpbmcsIGJ1dCBmb3IgQ0RhdGEqIGl0IGxldHMgeW91CisgICAgICAgIGdldCB0aGUgc3RyaW5nIHdpdGhvdXQgdGhlIENEYXRhIHdyYXBwZXIuIiIiCisgICAgICAgIGlmIGF0dHIgPT0gJ3N0cmluZyc6CisgICAgICAgICAgICByZXR1cm4gc2VsZgorICAgICAgICBlbHNlOgorICAgICAgICAgICAgcmFpc2UgQXR0cmlidXRlRXJyb3IoCisgICAgICAgICAgICAgICAgIiclcycgb2JqZWN0IGhhcyBubyBhdHRyaWJ1dGUgJyVzJyIgJSAoCisgICAgICAgICAgICAgICAgICAgIHNlbGYuX19jbGFzc19fLl9fbmFtZV9fLCBhdHRyKSkKKworICAgIGRlZiBvdXRwdXRfcmVhZHkoc2VsZiwgZm9ybWF0dGVyPSJtaW5pbWFsIik6CisgICAgICAgIG91dHB1dCA9IHNlbGYuZm9ybWF0X3N0cmluZyhzZWxmLCBmb3JtYXR0ZXIpCisg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lc3NpbmdJbnN0cnVjdGlvbihQcmVmb3JtYXR0ZWRTdHJpbmcpOgorCisgICAgUFJFRklYID0gdSc8PycKKyAgICBTVUZGSVggPSB1Jz8+JworCitjbGFzcyBDb21tZW50KFByZWZvcm1hdHRlZFN0cmluZyk6CisKKyAgICBQUkVGSVggPSB1JzwhLS0nCisgICAgU1VGRklYID0gdSctLT4nCisKKworY2xhc3MgRGVjbGFyYXRpb24oUHJlZm9ybWF0dGVkU3RyaW5nKToKKyAgICBQUkVGSVggPSB1JzwhJworICAgIFNVRkZJWCA9IHUnIT4nCisKKworY2xhc3MgRG9jdHlwZShQcmVmb3JtYXR0ZWRTdHJpbmcpOgorCisgICAgQGNsYXNzbWV0aG9kCisgICAgZGVmIGZvcl9uYW1lX2FuZF9pZHMoY2xzLCBuYW1lLCBwdWJfaWQsIHN5c3RlbV9pZCk6CisgICAgICAgIHZhbHVlID0gbmFtZSBvciAnJworICAgICAgICBpZiBwdWJfaWQgaXMgbm90IE5vbmU6CisgICAgICAgICAgICB2YWx1ZSArPSAnIFBVQkxJQyAiJXMiJyAlIHB1Yl9pZAorICAgICAgICAgICAgaWYgc3lzdGVtX2lkIGlzIG5vdCBOb25lOgorICAgICAgICAgICAgICAgIHZhbHVlICs9ICcgIiVzIicgJSBzeXN0ZW1faWQKKyAgICAgICAgZWxpZiBzeXN0ZW1faWQgaXMgbm90IE5vbmU6CisgICAgICAgICAgICB2YWx1ZSArPSAnIFNZU1RFTSAiJXMiJyAlIHN5c3RlbV9pZAorCisgICAgICAgIHJldHVybiBEb2N0eXBlKHZhbHVlKQorCisgICAgUFJFRklYID0gdSc8IURPQ1RZUEUgJworICAgIFNVRkZJWCA9IHUnPlxuJworCisKK2NsYXNzIFRhZyhQYWdlRWxlbWVudCk6CisKKyAgICAiIiJSZXByZXNlbnRzIGEgZm91bmQgSFRNTCB0YWcgd2l0aCBpdHMgYXR0cmlidXRlcyBhbmQgY29udGVudHMuIiIiCisKKyAgICBkZWYgX19pbml0X18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lIGFuZCB0eXBlKGRlc2NlbmRhbnQpIG5vdCBpbiB0eXBlcykpOgorICAgICAgICAgICAgICAgIGNvbnRpbnVlCisgICAgICAgICAgICBpZiBzdHJpcDoKKyAgICAgICAgICAgICAgICBkZXNjZW5kYW50ID0gZGVzY2VuZGFudC5zdHJpcCgpCisgICAgICAgICAgICAgICAgaWYgbGVuKGRlc2NlbmRhbnQpID09IDA6CisgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCisgICAgICAgICAgICB5aWVsZCBkZXNjZW5kYW50CisKKyAgICBzdHJpbmdzID0gcHJvcGVydHkoX2FsbF9zdHJpbmdzKQorCisgICAgQHByb3BlcnR5CisgICAgZGVmIHN0cmlwcGVkX3N0cmluZ3Moc2VsZik6CisgICAgICAgIGZvciBzdHJpbmcgaW4gc2VsZi5fYWxsX3N0cmluZ3MoVHJ1ZSk6CisgICAgICAgICAgICB5aWVsZCBzdHJpbmcKKworICAgIGRlZiBnZXRfdGV4dChzZWxmLCBzZXBhcmF0b3I9dSIiLCBzdHJpcD1GYWxzZSwKKyAgICAgICAgICAgICAgICAgdHlwZXM9KE5hdmlnYWJsZVN0cmluZywgQ0RhdGEpKToKKyAgICAgICAgIiIiCisgICAgICAgIEdldCBhbGwgY2hpbGQgc3RyaW5ncywgY29uY2F0ZW5hdGVkIHVzaW5nIHRoZSBnaXZlbiBzZXBhcmF0b3IuCisgICAgICAgICIiIgorICAgICAgICByZXR1cm4gc2VwYXJhdG9yLmpvaW4oW3MgZm9yIHMgaW4gc2VsZi5fYWxsX3N0cmluZ3MoCisgICAgICAgICAgICAgICAgICAgIHN0cmlwLCB0eXBlcz10eXBlcyldKQorICAgIGdldFRleHQgPSBnZXRfdGV4dAorICAgIHRleHQgPSBwcm9wZXJ0eShnZXRfdGV4dCkKKworICAgIGRlZiBkZWNvbXBvc2Uoc2VsZik6CisgICAgICAgICIiIlJlY3Vyc2l2ZWx5IGRlc3Ryb3lzIHRoZSBjb250ZW50cyBvZiB0aGlzIHRyZWUuIiIiCisgICAgICAgIHNlbGYuZXh0cmFjdCgpCisgICAgICAgIGkgPSBzZWxmCisgICAgICAgIHdoaWxlIGkgaXMgbm90IE5vbmU6CisgICAgICAgICAgICBuZXh0ID0gaS5uZXh0X2VsZW1lbnQKKyAgICAgICAgICAgIGkuX19kaWN0X18uY2xlYXIoKQorICAgICAgICAgICAgaS5jb250ZW50cyA9IFtdCisgICAgICAgICAgICBpID0gbmV4dAorCisgICAgZGVmIGNsZWFyKHNlbGYsIGRlY29tcG9zZT1GYWxzZSk6CisgICAgICAgICIiIgorICAgICAgICBFeHRyYWN0IGFsbCBjaGlsZHJlbi4gSWYgZGVjb21wb3NlIGlzIFRydWUsIGRlY29tcG9zZSBpbnN0ZWFkLgorICAgICAgICAiIiIKKyAgICAgICAgaWYgZGVjb21wb3NlOgorICAgICAgICAgICAgZm9yIGVsZW1lbnQgaW4gc2VsZi5jb250ZW50c1s6XToKKyAgICAgICAgICAgICAgICBpZiBpc2luc3RhbmNlKGVsZW1lbnQsIFRhZyk6CisgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZGVjb21wb3NlKCkKKyAgICAgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmV4dHJhY3QoKQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgZm9yIGVsZW1lbnQgaW4gc2VsZi5jb250ZW50c1s6XToKKyAgICAgICAgICAgICAgICBlbGVtZW50LmV4dHJhY3QoKQorCisgICAgZGVmIGluZGV4KHNlbGYsIGVsZW1lbnQpOgorICAgICAgICAiIiIKKyAgICAgICAgRmluZCB0aGUgaW5kZXggb2YgYSBjaGlsZCBieSBpZGVudGl0eSwgbm90IHZhbHVlLiBBdm9pZHMgaXNzdWVzIHdpdGgKKyAgICAgICAgdGFnLmNvbnRlbnRzLmluZGV4KGVsZW1lbnQpIGdldHRpbmcgdGhlIGluZGV4IG9mIGVxdWFsIGVsZW1lbnRzLgorICAgICAgICAiIiIKKyAgICA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1dGVzLAorICAgICAgICBhbmQgdGhlIHNhbWUgY29udGVudHMgKHJlY3Vyc2l2ZWx5KSBhcyB0aGUgZ2l2ZW4gdGFnLiIiIgorICAgICAgICBpZiBzZWxmIGlzIG90aGVyOgorICAgICAgICAgICAgcmV0dXJuIFRydWUKKyAgICAgICAgaWYgKG5vdCBoYXNhdHRyKG90aGVyLCAnbmFtZScpIG9yCisgICAgICAgICAgICBub3QgaGFzYXR0cihvdGhlciwgJ2F0dHJzJykgb3IKKyAgICAgICAgICAgIG5vdCBoYXNhdHRyKG90aGVyLCAnY29udGVudHMnKSBvcgorICAgICAgICAgICAgc2VsZi5uYW1lICE9IG90aGVyLm5hbWUgb3IKKyAgICAgICAgICAgIHNlbGYuYXR0cnMgIT0gb3RoZXIuYXR0cnMgb3IKKyAgICAgICAgICAgIGxlbihzZWxmKSAhPSBsZW4ob3RoZXIpKToKKyAgICAgICAgICAgIHJldHVybiBGYWxzZQorICAgICAgICBmb3IgaSwgbXlfY2hpbGQgaW4gZW51bWVyYXRlKHNlbGYuY29udGVudHMpOgorICAgICAgICAgICAgaWYgbXlfY2hpbGQgIT0gb3RoZXIuY29udGVudHNbaV06CisgICAgICAgICAgICAgICAgcmV0dXJuIEZhbHNlCisgICAgICAgIHJldHVybiBUcnVlCisKKyAgICBkZWYgX19uZV9fKHNlbGYsIG90aGVyKToKKyAgICAgICAgIiIiUmV0dXJucyB0cnVlIGlmZiB0aGlzIHRhZyBpcyBub3QgaWRlbnRpY2FsIHRvIHRoZSBvdGhlciB0YWcsCisgICAgICAgIGFzIGRlZmluZWQgaW4gX19lcV9fLiIiIgorICAgICAgICByZXR1cm4gbm90IHNlbGYgPT0gb3RoZXIKKworICAgIGRlZiBfX3JlcHJfXyhzZWxmLCBlbmNvZGluZz1ERUZBVUxUX09VVFBVVF9FTkNPRElORyk6CisgICAgICAgICIiIlJlbmRlcnMgdGhpcyB0YWcgYXMgYSBzdHJpbmcuIiIiCisgICAgICAgIHJldHVybiBzZWxm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AgICAgICBmb3Iga2V5LCB2YWwgaW4gc29ydGVkKHNlbGYuYXR0cnMuaXRlbXMoKSk6CisgICAgICAgICAgICAgICAgaWYgdmFsIGlzIE5vbmU6CisgICAgICAgICAgICAgICAgICAgIGRlY29kZWQgPSBrZXkKKyAgICAgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgICAgICBpZiBpc2luc3RhbmNlKHZhbCwgbGlzdCkgb3IgaXNpbnN0YW5jZSh2YWwsIHR1cGxlKToKKyAgICAgICAgICAgICAgICAgICAgICAgIHZhbCA9ICcgJy5qb2luKHZhbCkKKyAgICAgICAgICAgICAgICAgICAgZWxpZiBub3QgaXNpbnN0YW5jZSh2YWwsIGJhc2VzdHJpbmcpOgorICAgICAgICAgICAgICAgICAgICAgICAgdmFsID0gdW5pY29kZSh2YWwpCisgICAgICAgICAgICAgICAgICAgIGVsaWYgKAorICAgICAgICAgICAgICAgICAgICAgICAgaXNpbnN0YW5jZSh2YWwsIEF0dHJpYnV0ZVZhbHVlV2l0aENoYXJzZXRTdWJzdGl0dXRpb24pCisgICAgICAgICAgICAgICAgICAgICAgICBhbmQgZXZlbnR1YWxfZW5jb2RpbmcgaXMgbm90IE5vbmUpOgorICAgICAgICAgICAgICAgICAgICAgICAgdmFsID0gdmFsLmVuY29kZShldmVudHVhbF9lbmNvZGluZykKKworICAgICAgICAgICAgICAgICAgICB0ZXh0ID0gc2VsZi5mb3JtYXRfc3RyaW5nKHZhbCwgZm9ybWF0dGVyKQorICAgICAgICAgICAgICAgICAgICBkZWNvZGVkID0gKAorICAgICAgICAgICAgICAgICAgICAgICAgdW5pY29kZShrZXkpICsgJz0nCisgICAgICAgICAgICAgICAgICAgICAgICArIEVudGl0eVN1YnN0aXR1dGlvbi5xdW90ZWRfYXR0cmlidXRlX3ZhbHVlKHRleHQpKQorICAgICAgICAgICAgICAgIGF0dHJzLmFwcGVuZChkZWNvZGVkKQorICAgICAgICBjbG9zZSA9ICcnCisgICAgICAgIGNsb3NlVGFnID0gJycKKworICAgICAgICBwcmVmaXggPSAnJworICAgICAgICBpZiBzZWxmLnByZWZpeDoKKyAgICAgICAgICAgIHByZWZpeCA9IHNlbGYucHJlZml4ICsgIjoiCisKKyAgICAgICAgaWYgc2VsZi5pc19lbXB0eV9lbGVtZW50OgorICAgICAgICAgICAgY2xvc2UgPSAnLycKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIGNsb3NlVGFnID0gJzwvJXMlcz4nICUgKHByZWZpeCwgc2VsZi5uYW1lKQorCisgICAgICAgIHByZXR0eV9wcmludCA9IHNlbGYuX3Nob3VsZF9wcmV0dHlfcHJpbnQoaW5kZW50X2xldmVsKQorICAgICAgICBzcGFjZSA9ICcnCisgICAgICAgIGluZGVudF9zcGFjZSA9ICcnCisgICAgICAgIGlmIGluZGVudF9sZXZlbCBpcyBub3QgTm9uZToKKyAgICAgICAgICAgIGluZGVudF9zcGFjZSA9ICgnICcgKiAoaW5kZW50X2xldmVsIC0gMSkpCisgICAgICAgIGlmIHByZXR0eV9wcmludDoKKyAgICAgICAgICAgIHNwYWNlID0gaW5kZW50X3NwYWNlCisgICAgICAgICAgICBpbmRlbnRfY29udGVudHMgPSBpbmRlbnRfbGV2ZWwgKyAxCisgICAgICAgIGVsc2U6CisgICAgICAgICAgICBpbmRlbnRfY29udGVudHMgPSBOb25lCisgICAgICAgIGNvbnRlbnRzID0gc2VsZi5kZWNvZGVfY29udGVudHMoCisgICAgICAgICAgICBpbmRlbnRfY29udGVudHMsIGV2ZW50dWFsX2VuY29kaW5nLCBmb3JtYXR0ZXIpCisKKyAgICAgICAgaWYgc2VsZi5oaWRkZW46CisgICAgICAgICAgICAjIFRoaXMgaXMgdGhlICdkb2N1bWVudCByb290JyBvYmplY3QuCisgICAgICAgICAgICBzID0gY29udGVudHMKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIHMgPSBbXQorICAgICAgICAgICAgYXR0cmlidXRlX3N0cmluZyA9ICcnCisgICAgICAgICAgICBpZiBhdHRyczoKKyAgICAgICAgICAgICAgICBhdHRyaWJ1dGVfc3RyaW5nID0gJyAnICsgJyAnLmpvaW4oYXR0cnMpCisgICAgICAgICAgICBpZiBpbmRlbnRfbGV2ZWwgaXMgbm90IE5vbmU6CisgICAgICAgICAgICAgICAgIyBFdmVuIGlmIHRoaXMgcGFydGljdWxhciB0YWcgaXMgbm90IHByZXR0eS1wcmludGVkLAorICAgICAgICAgICAgICAgICMgd2Ugc2hvdWxkIGluZGVudCB1cCB0byB0aGUgc3RhcnQgb2YgdGhlIHRhZy4KKyAgICAgICAgICAgICAgICBzLmFwcGVuZChpbmRlbnRfc3BhY2UpCisgICAgICAgICAgICBzLmFwcGVuZCgnPCVzJXMlcyVzPicgJSAoCisgICAgICAgICAgICAgICAgICAgIHByZWZpeCwgc2VsZi5uYW1lLCBhdHRyaWJ1dGVfc3RyaW5nLCBjbG9zZSkpCisgICAgICAgICAgICBpZiBwcmV0dHlfcHJpbnQ6CisgICAgICAgICAgICAgICAgcy5hcHBlbmQoIlxuIikKKyAgICAgICAgICAgIHMuYXBwZW5kKGNvbnRlbnRzKQorICAgICAgICAgICAgaWYgcHJldHR5X3ByaW50IGFuZCBjb250ZW50cyBhbmQgY29udGVudHNbLTFdICE9ICJcbiI6CisgICAgICAgICAgICAgICAgcy5hcHBlbmQoIlxuIikKKyAgICAgICAgICAgIGlmIHByZXR0eV9wcmludCBhbmQgY2xvc2VUYWc6CisgICAgICAgICAgICAgICAgcy5hcHBlbmQoc3BhY2UpCisgICAgICAgICAgICBzLmFwcGVuZChjbG9zZVRhZykKKyAgICAgICAgICAgIGlmIGluZGVudF9sZXZlbCBpcyBub3QgTm9uZSBhbmQgY2xvc2VUYWcgYW5kIHNlbGYubmV4dF9zaWJsaW5nOgorICAgICAgICAgICAgICAgICMgRXZlbiBpZiB0aGlzIHBhcnRpY3VsYXIgdGFnIGlzIG5vdCBwcmV0dHktcHJpbnRlZCwKKyAgICAgICAgICAgICAgICAjIHdlJ3JlIG5vdyBkb25lIHdpdGggdGhlIHRhZywgYW5kIHdlIHNob3VsZCBhZGQgYQorICAgICAgICAgICAgICAgICMgbmV3bGluZSBpZiBhcHByb3ByaWF0ZS4KKyAgICAgICAgICAgICAgICBzLmFwcGVuZCgiXG4iKQorICAgICAgICAgICAgcyA9ICcnLmpvaW4ocykKKyAgICAgICAgcmV0dXJuIHMKKworICAgIGRlZiBwcmV0dGlmeShzZWxmLCBlbmNvZGluZz1Ob25lLCBmb3JtYXR0ZXI9Im1pbmltYWwiKToKKyAgICAgICAgaWYgZW5jb2RpbmcgaXMgTm9uZToKKyAgICAgICAgICAgIHJldHVybiBzZWxmLmRlY29kZShUcnVlLCBmb3JtYXR0ZXI9Zm9ybWF0dGVyKQorICAgICAgICBlbHNlOgorICAgICAgICAgICAgcmV0dXJuIHNlbGYuZW5jb2RlKGVuY29kaW5nLCBUcnVlLCBmb3JtYXR0ZXI9Zm9ybWF0dGVyKQorCisgICAgZGVmIGRlY29kZV9jb250ZW50cyhzZWxmLCBpbmRlbnRfbGV2ZWw9Tm9uZSwKKyAgICAgICAgICAgICAgICAgICAgICAgZXZlbnR1YWxfZW5jb2Rpbmc9REVGQVVMVF9PVVRQVVRfRU5DT0RJTkcsCisgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdHRlcj0ibWluaW1hbCIpOgorICAgICAgICAiIiJSZW5kZXJzIHRoZSBjb250ZW50cyBvZiB0aGlzIHRhZyBhcyBhIFVuaWNvZGUgc3RyaW5nLgorCisgICAgICAgIDpwYXJhbSBldmVudHVhbF9lbmNvZGluZzogVGhlIHRhZyBpcyBkZXN0aW5lZCB0byBiZQorICAgICAgICAgICBlbmNvZGVkIGludG8gdGhpcyBlbmNvZGluZy4gVGhpcyBtZXRob2QgaXMgX25vdF8KKyAgICAgICAgICAgcmVzcG9uc2libGUgZm9yIHBlcmZvcm1pbmcgdGhhdCBlbmNvZGluZy4gVGhpcyBpbmZvcm1hdGlvbgorICAgICAgICAgICBpcyBwYXNzZWQgaW4gc28gdGhhdCBpdCBjYW4gYmUgc3Vic3RpdHV0ZWQgaW4gaWYgdGhlCisgICAgICAgICAgIGRvY3VtZW50IGNvbnRhaW5zIGEgPE1FVEE+IHRhZyB0aGF0IG1lbnRpb25zIHRoZSBkb2N1bWVudCdzCisgICAgICAgICAgIGVuY29kaW5nLgorICAgICAgICAiIiIKKyAgICAgICAgIyBGaXJzdCBvZmYsIHR1cm4gYSBzdHJpbmcgZm9ybWF0dGVyIGludG8gYSBmdW5jdGlvbi4gVGhpcworICAgICAgICAjIHdpbGwgc3RvcCB0aGUgbG9va3VwIGZyb20gaGFwcGVuaW5nIG92ZXIgYW5kIG92ZXIgYWdhaW4uCisgICAgICAgIGlmIG5vdCBjYWxsYWJsZShmb3JtYXR0ZXIpOgorICAgICAgICAgICAgZm9ybWF0dGVyID0gc2VsZi5fZm9ybWF0dGVyX2Zvcl9uYW1lKGZvcm1hdHRlcikKKworICAgICAgICBwcmV0dHlfcHJpbnQgPSAoaW5kZW50X2xldmVsIGlzIG5vdCBOb25lKQorICAgICAgICBzID0gW10KKyAgICAgICAgZm9yIGMgaW4gc2VsZjoKKyAgICAgICAgICAgIHRleHQgPSBOb25lCisgICAgICAgICAgICBpZiBpc2luc3RhbmNlKGMsIE5hdmlnYWJsZVN0cmluZyk6CisgICAgICAgICAgICAgICAgdGV4dCA9IGMub3V0cHV0X3JlYWR5KGZvcm1hdHRlcikKKyAgICAgICAgICAgIGVsaWYgaXNpbnN0YW5jZShjLCBUYWcpOgorICAgICAgICAgICAgICAgIHMuYXBwZW5kKGMuZGVjb2RlKGluZGVudF9sZXZlbCwgZXZlbnR1YWxfZW5jb2RpbmcsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVyKSkKKyAgICAgICAgICAgIGlmIHRleHQgYW5kIGluZGVudF9sZXZlbCBhbmQgbm90IHNlbGYubmFtZSA9PSAncHJlJzoKKyAgICAgICAgICAgICAgICB0ZXh0ID0gdGV4dC5zdHJpcCgpCisgICAgICAgICAgICBpZiB0ZXh0OgorICAgICAgICAgICAgICAgIGlmIHByZXR0eV9wcmludCBhbmQgbm90IHNlbGYubmFtZSA9PSAncHJlJzoKKyAgICAgICAgICAgICAgICAgICAgcy5hcHBlbmQoIiAiICogKGluZGVudF9sZXZlbCAtIDEpKQorICAgICAgICAgICAgICAgIHMuYXBwZW5kKHRleHQpCisgICAgICAgICAgICAgICAgaWYgcHJldHR5X3ByaW50IGFuZCBub3Qgc2VsZi5uYW1lID09ICdwcmUnOgorICAgICAgICAgICAgICAgICAgICBzLmFwcGVuZCgiXG4iKQorICAgICAgICByZXR1cm4gJycuam9pbihzKQorCisgICAgZGVmIGVuY29kZV9jb250ZW50cygKKyAgICAgICAgc2VsZiwgaW5kZW50X2xldmVsPU5vbmUsIGVuY29kaW5nPURFRkFVTFRfT1VUUFVUX0VOQ09ESU5HLAorICAgICAgICBmb3JtYXR0ZXI9Im1pbmltYWwiKToKKyAgICAgICAgIiIiUmVuZGVycyB0aGUgY29udGVudHMgb2YgdGhpcyB0YWcgYXMgYSBieXRlc3RyaW5nLiIiIgorICAgICAgICBjb250ZW50cyA9IHNlbGYuZGVjb2RlX2NvbnRlbnRzKGluZGVudF9sZXZlbCwgZW5jb2RpbmcsIGZvcm1hdHRlcikKKyAgICAgICAgcmV0dXJuIGNvbnRlbnRzLmVuY29kZShlbmNvZGluZykKKworICAgICMgT2xkIG1ldGhvZCBmb3IgQlMzIGNvbXBhdGliaWxpdHkKKyAgICBkZWYgcmVuZGVyQ29udGVudHMoc2VsZiwgZW5jb2Rpbmc9REVGQVVMVF9PVVRQVVRfRU5DT0RJTkcsCisgICAgICAgICAgICAgICAgICAgICAgIHByZXR0eVByaW50PUZhbHNlLCBpbmRlbnRMZXZlbD0wKToKKyAgICAgICAgaWYgbm90IHByZXR0eVByaW50OgorICAgICAgICAgICAgaW5kZW50TGV2ZWwgPSBOb25lCisgICAgICAgIHJldHVybiBzZWxmLmVuY29kZV9jb250ZW50cyg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KyAgICAgICAgICAgIHJlY3Vyc2l2ZV9jYW5kaWRhdGVfZ2VuZXJhdG9yID0gTm9uZQorICAgICAgICAgICAgdGFnX25hbWUgPSBOb25lCisgICAgICAgICAgICBpZiB0b2tlbnNbaW5kZXgtMV0gaW4gc2VsZi5fc2VsZWN0b3JfY29tYmluYXRvcnM6CisgICAgICAgICAgICAgICAgIyBUaGlzIHRva2VuIHdhcyBjb25zdW1lZCBieSB0aGUgcHJldmlvdXMgY29tYmluYXRvci4gU2tpcCBpdC4KKyAgICAgICAgICAgICAgICBpZiBzZWxmLl9zZWxlY3RfZGVidWc6CisgICAgICAgICAgICAgICAgICAgIHByaW50ICcgIFRva2VuIHdhcyBjb25zdW1lZCBieSB0aGUgcHJldmlvdXMgY29tYmluYXRvci4nCisgICAgICAgICAgICAgICAgY29udGludWUKKyAgICAgICAgICAgICMgRWFjaCBvcGVyYXRpb24gY29ycmVzcG9uZHMgdG8gYSBjaGVja2VyIGZ1bmN0aW9uLCBhIHJ1bGUKKyAgICAgICAgICAgICMgZm9yIGRldGVybWluaW5nIHdoZXRoZXIgYSBjYW5kaWRhdGUgbWF0Y2hlcyB0aGUKKyAgICAgICAgICAgICMgc2VsZWN0b3IuIENhbmRpZGF0ZXMgYXJlIGdlbmVyYXRlZCBieSB0aGUgYWN0aXZlCisgICAgICAgICAgICAjIGl0ZXJhdG9yLgorICAgICAgICAgICAgY2hlY2tlciA9IE5vbmUKKworICAgICAgICAgICAgbSA9IHNlbGYuYXR0cmlic2VsZWN0X3JlLm1hdGNoKHRva2VuKQorICAgICAgICAgICAgaWYgbSBpcyBub3QgTm9uZToKKyAgICAgICAgICAgICAgICAjIEF0dHJpYnV0ZSBzZWxlY3RvcgorICAgICAgICAgICAgICAgIHRhZ19uYW1lLCBhdHRyaWJ1dGUsIG9wZXJhdG9yLCB2YWx1ZSA9IG0uZ3JvdXBzKCkKKyAgICAgICAgICAgICAgICBjaGVja2VyID0gc2VsZi5fYXR0cmlidXRlX2NoZWNrZXIob3BlcmF0b3IsIGF0dHJpYnV0ZSwgdmFsdWUpCisKKyAgICAgICAgICAgIGVsaWYgJyMnIGluIHRva2VuOgorICAgICAgICAgICAgICAgICMgSUQgc2VsZWN0b3IKKyAgICAgICAgICAgICAgICB0YWdfbmFtZSwgdGFnX2lkID0gdG9rZW4uc3BsaXQoJyMnLCAxKQorICAgICAgICAgICAgICAgIGRlZiBpZF9tYXRjaGVzKHRhZyk6CisgICAgICAgICAgICAgICAgICAgIHJldHVybiB0YWcuZ2V0KCdpZCcsIE5vbmUpID09IHRhZ19pZAorICAgICAgICAgICAgICAgIGNoZWNrZXIgPSBpZF9tYXRjaGVzCisKKyAgICAgICAgICAgIGVsaWYgJy4nIGluIHRva2VuOgorICAgICAgICAgICAgICAgICMgQ2xhc3Mgc2VsZWN0b3IKKyAgICAgICAgICAgICAgICB0YWdfbmFtZSwga2xhc3MgPSB0b2tlbi5zcGxpdCgnLicsIDEpCisgICAgICAgICAgICAgICAgY2xhc3NlcyA9IHNldChrbGFzcy5zcGxpdCgnLicpKQorICAgICAgICAgICAgICAgIGRlZiBjbGFzc2VzX21hdGNoKGNhbmRpZGF0ZSk6CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBjbGFzc2VzLmlzc3Vic2V0KGNhbmRpZGF0ZS5nZXQoJ2NsYXNzJywgW10pKQorICAgICAgICAgICAgICAgIGNoZWNrZXIgPSBjbGFzc2VzX21hdGNoCisKKyAgICAgICAgICAgIGVsaWYgJzonIGluIHRva2VuOgorICAgICAgICAgICAgICAgICMgUHNldWRvLWNsYXNzCisgICAgICAgICAgICAgICAgdGFnX25hbWUsIHBzZXVkbyA9IHRva2VuLnNwbGl0KCc6JywgMSkKKyAgICAgICAgICAgICAgICBpZiB0YWdfbmFtZSA9PSAnJzoKKyAgICAgICAgICAgICAgICAgICAgcmFpc2UgVmFsdWVFcnJvcigKKyAgICAgICAgICAgICAgICAgICAgICAgICJBIHBzZXVkby1jbGFzcyBtdXN0IGJlIHByZWZpeGVkIHdpdGggYSB0YWcgbmFtZS4iKQorICAgICAgICAgICAgICAgIHBzZXVkb19hdHRyaWJ1dGVzID0gcmUubWF0Y2goJyhbYS16QS1aXGQtXSspXCgoW2EtekEtWlxkXSspXCknLCBwc2V1ZG8pCisgICAgICAgICAgICAgICAgZm91bmQgPSBbXQorICAgICAgICAgICAgICAgIGlmIHBzZXVkb19hdHRyaWJ1dGVzIGlzIG5vdCBOb25lOgorICAgICAgICAgICAgICAgICAgICBwc2V1ZG9fdHlwZSwgcHNldWRvX3ZhbHVlID0gcHNldWRvX2F0dHJpYnV0ZXMuZ3JvdXBzKCkKKyAgICAgICAgICAgICAgICAgICAgaWYgcHNldWRvX3R5cGUgPT0gJ250aC1vZi10eXBlJzoKKyAgICAgICAgICAgICAgICAgICAgICAgIHRyeToKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBwc2V1ZG9fdmFsdWUgPSBpbnQocHNldWRvX3ZhbHVlKQorICAgICAgICAgICAgICAgICAgICAgICAgZXhjZXB0OgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhaXNlIE5vdEltcGxlbWVudGVkRXJyb3IoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICdPbmx5IG51bWVyaWMgdmFsdWVzIGFyZSBjdXJyZW50bHkgc3VwcG9ydGVkIGZvciB0aGUgbnRoLW9mLXR5cGUgcHNldWRvLWNsYXNzLicpCisgICAgICAgICAgICAgICAgICAgICAgICBpZiBwc2V1ZG9fdmFsdWUgPCAxOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhaXNlIFZhbHVlRXJyb3IoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICdudGgtb2YtdHlwZSBwc2V1ZG8tY2xhc3MgdmFsdWUgbXVzdCBiZSBhdCBsZWFzdCAxLicpCisgICAgICAgICAgICAgICAgICAgICAgICBjbGFzcyBDb3VudGVyKG9iamVjdCk6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmIF9faW5pdF9fKHNlbGYsIGRlc3RpbmF0aW9uKToKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5jb3VudCA9IDAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5kZXN0aW5hdGlvbiA9IGRlc3RpbmF0aW9uCisKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWYgbnRoX2NoaWxkX29mX3R5cGUoc2VsZiwgdGFnKToKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5jb3VudCArPSAxCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIHNlbGYuY291bnQgPT0gc2VsZi5kZXN0aW5hdGlvbjoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBUcnVlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIHNlbGYuY291bnQgPiBzZWxmLmRlc3RpbmF0aW9uOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIyBTdG9wIHRoZSBnZW5lcmF0b3IgdGhhdCdzIHNlbmRpbmcgdXMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgdGhlc2UgdGhpbmdzLgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFpc2UgU3RvcEl0ZXJhdGlvbigpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBGYWxzZQorICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tlciA9IENvdW50ZXIocHNldWRvX3ZhbHVlKS5udGhfY2hpbGRfb2ZfdHlwZQorICAgICAgICAgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgICAgICAgICAgcmFpc2UgTm90SW1wbGVtZW50ZWRFcnJvcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAnT25seSB0aGUgZm9sbG93aW5nIHBzZXVkby1jbGFzc2VzIGFyZSBpbXBsZW1lbnRlZDogbnRoLW9mLXR5cGUuJykKKworICAgICAgICAgICAgZWxpZiB0b2tlbiA9PSAnKic6CisgICAgICAgICAgICAgICAgIyBTdGFyIHNlbGVjdG9yIC0tIG1hdGNoZXMgZXZlcnl0aGluZworICAgICAgICAgICAgICAgIHBhc3MKKyAgICAgICAgICAgIGVsaWYgdG9rZW4gPT0gJz4nOgorICAgICAgICAgICAgICAgICMgUnVuIHRoZSBuZXh0IHRva2VuIGFzIGEgQ1NTIHNlbGVjdG9yIGFnYWluc3QgdGhlCisgICAgICAgICAgICAgICAgIyBkaXJlY3QgY2hpbGRyZW4gb2YgZWFjaCB0YWcgaW4gdGhlIGN1cnJlbnQgY29udGV4dC4KKyAgICAgICAgICAgICAgICByZWN1cnNpdmVfY2FuZGlkYXRlX2dlbmVyYXRvciA9IGxhbWJkYSB0YWc6IHRhZy5jaGlsZHJlbgorICAgICAgICAgICAgZWxpZiB0b2tlbiA9PSAnfic6CisgICAgICAgICAgICAgICAgIyBSdW4gdGhlIG5leHQgdG9rZW4gYXMgYSBDU1Mgc2VsZWN0b3IgYWdhaW5zdCB0aGUKKyAgICAgICAgICAgICAgICAjIHNpYmxpbmdzIG9mIGVhY2ggdGFnIGluIHRoZSBjdXJyZW50IGNvbnRleHQuCisgICAgICAgICAgICAgICAgcmVjdXJzaXZlX2NhbmRpZGF0ZV9nZW5lcmF0b3IgPSBsYW1iZGEgdGFnOiB0YWcubmV4dF9zaWJsaW5ncworICAgICAgICAgICAgZWxpZiB0b2tlbiA9PSAnKyc6CisgICAgICAgICAgICAgICAgIyBGb3IgZWFjaCB0YWcgaW4gdGhlIGN1cnJlbnQgY29udGV4dCwgcnVuIHRoZSBuZXh0CisgICAgICAgICAgICAgICAgIyB0b2tlbiBhcyBhIENTUyBzZWxlY3RvciBhZ2FpbnN0IHRoZSB0YWcncyBuZXh0CisgICAgICAgICAgICAgICAgIyBzaWJsaW5nIHRoYXQncyBhIHRhZy4KKyAgICAgICAgICAgICAgICBkZWYgbmV4dF90YWdfc2libGluZyh0YWcpOgorICAgICAgICAgICAgICAgICAgICB5aWVsZCB0YWcuZmluZF9uZXh0X3NpYmxpbmcoVHJ1ZSkKKyAgICAgICAgICAgICAgICByZWN1cnNpdmVfY2FuZGlkYXRlX2dlbmVyYXRvciA9IG5leHRfdGFnX3NpYmxpbmcKKworICAgICAgICAgICAgZWxpZiBzZWxmLnRhZ19uYW1lX3JlLm1hdGNoKHRva2VuKToKKyAgICAgICAgICAgICAgICAjIEp1c3QgYSB0YWcgbmFtZS4KKyAgICAgICAgICAgICAgICB0YWdfbmFtZSA9IHRva2VuCisgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgIHJhaXNlIFZhbHVlRXJyb3IoCisgICAgICAgICAgICAgICAgICAgICdVbnN1cHBvcnRlZCBvciBpbnZhbGlkIENTUyBzZWxlY3RvcjogIiVzIicgJSB0b2tlbikKKworICAgICAgICAgICAgaWYgcmVjdXJzaXZlX2NhbmRpZGF0ZV9nZW5lcmF0b3I6CisgICAgICAgICAgICAgICAgIyBUaGlzIGhhcHBlbnMgd2hlbiB0aGUgc2VsZWN0b3IgbG9va3MgbGlrZSAgIj4gZm9vIi4KKyAgICAgICAgICAgICAgICAjCisgICAgICAgICAgICAgICAgIyBUaGUgZ2VuZXJhdG9yIGNhbGxzIHNlbGVjdCgpIHJlY3Vyc2l2ZWx5IG9uIGV2ZXJ5CisgICAgICAgICAgICAgICAgIyBtZW1iZXIgb2YgdGhlIGN1cnJlbnQgY29udGV4dCwgcGFzc2luZyBpbiBhIGRpZmZlcmVudAorICAgICAgICAgICAgICAgICMgY2FuZGlkYXRlIGdlbmVyYXRvciBhbmQgYSBkaWZmZXJlbnQgc2VsZWN0b3IuCisgICAgICAgICAgICAgICAgIworICAgICAgICAgICAgICAgICMgSW4gdGhlIGNhc2Ugb2YgIj4gZm9vIiwgdGhlIGNhbmRpZGF0ZSBnZW5lcmF0b3IgaXMKKyAgICAgICAgICAgICAgICAjIG9uZSB0aGF0IHlpZWxkcyBhIHRhZydzIGRpcmVjdCBjaGlsZHJlbiAoIj4iKSwgYW5kCisgICAgICAgICAgICAgICAgIyB0aGUgc2VsZWN0b3IgaXMgImZvbyIuCisgICAgICAgICAgICAgICAgbmV4dF90b2tlbiA9IHRva2Vuc1tpbmRleCsxXQorICAgICAgICAgICAgICAgIGRlZiByZWN1cnNpdmVfc2VsZWN0KHRhZyk6CisgICAgICAgICAgICAgICAgICAgIGlmIHNlbGYuX3NlbGVjdF9kZWJ1ZzoKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50ICcgICAgQ2FsbGluZyBzZWxlY3QoIiVzIikgcmVjdXJzaXZlbHkgb24gJXMgJXMnICUgKG5leHRfdG9rZW4sIHRhZy5uYW1lLCB0YWcuYXR0cnMpCisgICAgICAgICAgICAgICAgICAgICAgICBwcmludCAnLScgKiA0MAorICAgICAgICAgICAgICAgICAgICBmb3IgaSBpbiB0YWcuc2VsZWN0KG5leHRfdG9rZW4sIHJlY3Vyc2l2ZV9jYW5kaWRhdGVfZ2VuZXJhdG9yKToKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIHNlbGYuX3NlbGVjdF9kZWJ1ZzoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludCAnKFJlY3Vyc2l2ZSBzZWxlY3QgcGlja2VkIHVwIGNhbmRpZGF0ZSAlcyAlcyknICUgKGkubmFtZSwgaS5hdHRycykKKyAgICAgICAgICAgICAgICAgICAgICAgIHlpZWxkIGkKKyAgICAgICAgICAgICAgICAgICAgaWYgc2VsZi5fc2VsZWN0X2RlYnVnOgorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQgJy0nICogNDAKKyAgICAgICAgICAgICAgICBfdXNlX2NhbmRpZGF0ZV9nZW5lcmF0b3IgPSByZWN1cnNpdmVfc2VsZWN0CisgICAgICAgICAgICBlbGlmIF9jYW5kaWRhdGVfZ2VuZXJhdG9yIGlzIE5vbmU6CisgICAgICAgICAgICAgICAgIyBCeSBkZWZhdWx0LCBhIHRhZydzIGNhbmRpZGF0ZXMgYXJlIGFsbCBvZiBpdHMKKyAgICAgICAgICAgICAgICAjIGNoaWxkcmVuLiBJZiB0YWdfbmFtZSBpcyBkZWZpbmVkLCBvbmx5IHlpZWxkIHRhZ3MKKyAgICAgICAgICAgICAgICAjIHdpdGggdGhhdCBuYW1lLgorICAgICAgICAgICAgICAgIGlmIHNlbGYuX3NlbGVjdF9kZWJ1ZzoKKyAgICAgICAgICAgICAgICAgICAgaWYgdGFnX25hbWU6CisgICAgICAgICAgICAgICAgICAgICAgICBjaGVjayA9ICJbYW55XSIKKyAgICAgICAgICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrID0gdGFnX25hbWUKKyAgICAgICAgICAgICAgICAgICAgcHJpbnQgJyAgIERlZmF1bHQgY2FuZGlkYXRlIGdlbmVyYXRvciwgdGFnIG5hbWU9IiVzIicgJSBjaGVjaworICAgICAgICAgICAgICAgIGlmIHNlbGYuX3NlbGVjdF9kZWJ1ZzoKKyAgICAgICAgICAgICAgICAgICAgIyBUaGlzIGlzIHJlZHVuZGFudCB3aXRoIGxhdGVyIGNvZGUsIGJ1dCBpdCBzdG9wcworICAgICAgICAgICAgICAgICAgICAjIGEgYnVuY2ggb2YgYm9ndXMgdGFncyBmcm9tIGNsdXR0ZXJpbmcgdXAgdGhlCisgICAgICAgICAgICAgICAgICAgICMgZGVidWcgbG9nLgorICAgICAgICAgICAgICAgICAgICBkZWYgZGVmYXVsdF9jYW5kaWRhdGVfZ2VuZXJhdG9yKHRhZyk6CisgICAgICAgICAgICAgICAgICAgICAgICBmb3IgY2hpbGQgaW4gdGFnLmRlc2NlbmRhbnRzOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIG5vdCBpc2luc3RhbmNlKGNoaWxkLCBUYWcpOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIHRhZ19uYW1lIGFuZCBub3QgY2hpbGQubmFtZSA9PSB0YWdfbmFtZToKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB5aWVsZCBjaGlsZAorICAgICAgICAgICAgICAgICAgICBfdXNlX2NhbmRpZGF0ZV9nZW5lcmF0b3IgPSBkZWZhdWx0X2NhbmRpZGF0ZV9nZW5lcmF0b3IKKyAgICAgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgICAgICBfdXNlX2NhbmRpZGF0ZV9nZW5lcmF0b3IgPSBsYW1iZGEgdGFnOiB0YWcuZGVzY2VuZGFudHMKKyAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAgICAgICAgX3VzZV9jYW5kaWRhdGVfZ2VuZXJhdG9yID0gX2NhbmRpZGF0ZV9nZW5lcmF0b3IKKworICAgICAgICAgICAgbmV3X2NvbnRleHQgPSBbXQorICAgICAgICAgICAgbmV3X2NvbnRleHRfaWRzID0gc2V0KFtdKQorICAgICAgICAgICAgZm9yIHRhZyBpbiBjdXJyZW50X2NvbnRleHQ6CisgICAgICAgICAgICAgICAgaWYgc2VsZi5fc2VsZWN0X2RlYnVnOgorICAgICAgICAgICAgICAgICAgICBwcmludCAiICAgIFJ1bm5pbmcgY2FuZGlkYXRlIGdlbmVyYXRvciBvbiAlcyAlcyIgJSAoCisgICAgICAgICAgICAgICAgICAgICAgICB0YWcubmFtZSwgcmVwcih0YWcuYXR0cnMpKQorICAgICAgICAgICAgICAgIGZvciBjYW5kaWRhdGUgaW4gX3VzZV9jYW5kaWRhdGVfZ2VuZXJhdG9yKHRhZyk6CisgICAgICAgICAgICAgICAgICAgIGlmIG5vdCBpc2luc3RhbmNlKGNhbmRpZGF0ZSwgVGFnKToKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCisgICAgICAgICAgICAgICAgICAgIGlmIHRhZ19uYW1lIGFuZCBjYW5kaWRhdGUubmFtZSAhPSB0YWdfbmFtZToKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCisgICAgICAgICAgICAgICAgICAgIGlmIGNoZWNrZXIgaXMgbm90IE5vbmU6CisgICAgICAgICAgICAgICAgICAgICAgICB0cnk6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gY2hlY2tlcihjYW5kaWRhdGUpCisgICAgICAgICAgICAgICAgICAgICAgICBleGNlcHQgU3RvcEl0ZXJhdGlvbjoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAjIFRoZSBjaGVja2VyIGhhcyBkZWNpZGVkIHdlIHNob3VsZCBubyBsb25nZXIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAjIHJ1biB0aGUgZ2VuZXJhdG9yLgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrCisgICAgICAgICAgICAgICAgICAgIGlmIGNoZWNrZXIgaXMgTm9uZSBvciByZXN1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICBpZiBzZWxmLl9zZWxlY3RfZGVidWc6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQgIiAgICAgU1VDQ0VTUyAlcyAlcyIgJSAoY2FuZGlkYXRlLm5hbWUsIHJlcHIoY2FuZGlkYXRlLmF0dHJzKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIGlkKGNhbmRpZGF0ZSkgbm90IGluIG5ld19jb250ZXh0X2lkczoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAjIElmIGEgdGFnIG1hdGNoZXMgYSBzZWxlY3RvciBtb3JlIHRoYW4gb25jZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAjIGRvbid0IGluY2x1ZGUgaXQgaW4gdGhlIGNvbnRleHQgbW9yZSB0aGFuIG9uY2UuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3X2NvbnRleHQuYXBwZW5kKGNhbmRpZGF0ZSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdfY29udGV4dF9pZHMuYWRkKGlkKGNhbmRpZGF0ZSkpCisgICAgICAgICAgICAgICAgICAgIGVsaWYgc2VsZi5fc2VsZWN0X2RlYnVnOgorICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQgIiAgICAgRkFJTFVSRSAlcyAlcyIgJSAoY2FuZGlkYXRlLm5hbWUsIHJlcHIoY2FuZGlkYXRlLmF0dHJzKSkKKworICAgICAgICAgICAgY3VycmVudF9jb250ZXh0ID0gbmV3X2NvbnRleHQKKworICAgICAgICBpZiBzZWxmLl9zZWxlY3RfZGVidWc6CisgICAgICAgICAgICBwcmludCAiRmluYWwgdmVyZGljdDoiCisgICAgICAgICAgICBmb3IgaSBpbiBjdXJyZW50X2NvbnRleHQ6CisgICAgICAgICAgICAgICAgcHJpbnQgIiAlcyAlcyIgJSAoaS5uYW1lLCBpLmF0dHJzKQorICAgICAgICByZXR1cm4gY3VycmVudF9jb250ZXh0CisKKyAgICAjIE9sZCBuYW1lcyBmb3IgYmFja3dhcmRzIGNvbXBhdGliaWxpdHkKKyAgICBkZWYgY2hpbGRHZW5lcmF0b3Ioc2VsZik6CisgICAgICAgIHJldHVybiBzZWxmLmNoaWxkcmVuCisKKyAgICBkZWYgcmVjdXJzaXZlQ2hpbGRHZW5lcmF0b3Ioc2VsZik6CisgICAgICAgIHJldHVybiBzZWxmLmRlc2NlbmRhbnRzCisKKyAgICBkZWYgaGFzX2tleShzZWxmLCBrZXkpOgorICAgICAgICAiIiJUaGlzIHdhcyBraW5kIG9mIG1pc2xlYWRpbmcgYmVjYXVzZSBoYXNfa2V5KCkgKGF0dHJpYnV0ZXMpCisgICAgICAgIHdhcyBkaWZmZXJlbnQgZnJvbSBfX2luX18gKGNvbnRlbnRzKS4gaGFzX2tleSgpIGlzIGdvbmUgaW4KKyAgICAgICAgUHl0aG9uIDMsIGFueXdheS4iIiIKKyAgICAgICAgd2FybmluZ3Mud2FybignaGFzX2tleSBpcyBkZXByZWNhdGV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FzIFVURi04LgorICAgICAgICBpZiBpc2luc3RhbmNlKHZhbHVlLCBieXRlcyk6CisgICAgICAgICAgICByZXR1cm4gdmFsdWUuZGVjb2RlKCJ1dGY4IikKKworICAgICAgICAjIElmIGl0J3MgbGlzdGxpa2UsIGNvbnZlcnQgaXQgaW50byBhIGxpc3Qgb2Ygc3RyaW5ncy4KKyAgICAgICAgaWYgaGFzYXR0cih2YWx1ZSwgJ19faXRlcl9fJyk6CisgICAgICAgICAgICBuZXdfdmFsdWUgPSBbXQorICAgICAgICAgICAgZm9yIHYgaW4gdmFsdWU6CisgICAgICAgICAgICAgICAgaWYgKGhhc2F0dHIodiwgJ19faXRlcl9fJykgYW5kIG5vdCBpc2luc3RhbmNlKHYsIGJ5dGVzKQorICAgICAgICAgICAgICAgICAgICBhbmQgbm90IGlzaW5zdGFuY2UodiwgdW5pY29kZSkpOgorICAgICAgICAgICAgICAgICAgICAjIFRoaXMgaXMgYWxtb3N0IGNlcnRhaW5seSB0aGUgdXNlcidzIG1pc3Rha2UuIEluIHRoZQorICAgICAgICAgICAgICAgICAgICAjIGludGVyZXN0cyBvZiBhdm9pZGluZyBpbmZpbml0ZSBsb29wcywgd2UnbGwgbGV0CisgICAgICAgICAgICAgICAgICAgICMgaXQgdGhyb3VnaCBhcy1pcyByYXRoZXIgdGhhbiBkb2luZyBhIHJlY3Vyc2l2ZSBjYWxsLgorICAgICAgICAgICAgICAgICAgICBuZXdfdmFsdWUuYXBwZW5kKHYpCisgICAgICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICAgICAgbmV3X3ZhbHVlLmFwcGVuZChzZWxmLl9ub3JtYWxpemVfc2VhcmNoX3ZhbHVlKHYpKQorICAgICAgICAgICAgcmV0dXJuIG5ld192YWx1ZQorCisgICAgICAgICMgT3RoZXJ3aXNlLCBjb252ZXJ0IGl0IGludG8gYSBVbmljb2RlIHN0cmluZy4KKyAgICAgICAgIyBUaGUgdW5pY29kZShzdHIoKSkgdGhpbmcgaXMgc28gdGhpcyB3aWxsIGRvIHRoZSBzYW1lIHRoaW5nIG9uIFB5dGhvbiAyCisgICAgICAgICMgYW5kIFB5dGhvbiAzLgorICAgICAgICByZXR1cm4gdW5pY29kZShzdHIodmFsdWUpKQorCisgICAgZGVmIF9fc3RyX18oc2VsZik6CisgICAgICAgIGlmIHNlbGYudGV4dDoKKyAgICAgICAgICAgIHJldHVybiBzZWxmLnRleHQKKyAgICAgICAgZWxzZToKKyAgICAgICAgICAgIHJldHVybiAiJXN8JXMiICUgKHNlbGYubmFtZSwgc2VsZi5hdHRycykKKworICAgIGRlZiBzZWFyY2hfdGFnKHNlbGYsIG1hcmt1cF9uYW1lPU5vbmUsIG1hcmt1cF9hdHRycz17fSk6CisgICAgICAgIGZvdW5kID0gTm9uZQorICAgICAgICBtYXJrdXAgPSBOb25lCisgICAgICAgIGlmIGlzaW5zdGFuY2UobWFya3VwX25hbWUsIFRhZyk6CisgICAgICAgICAgICBtYXJrdXAgPSBtYXJrdXBfbmFtZQorICAgICAgICAgICAgbWFya3VwX2F0dHJzID0gbWFya3VwCisgICAgICAgIGNhbGxfZnVuY3Rpb25fd2l0aF90YWdfZGF0YSA9ICgKKyAgICAgICAgICAgIGlzaW5zdGFuY2Uoc2VsZi5uYW1lLCBjb2xsZWN0aW9ucy5DYWxsYWJsZSkKKyAgICAgICAgICAgIGFuZCBub3QgaXNpbnN0YW5jZShtYXJrdXBfbmFtZSwgVGFnKSkKKworICAgICAgICBpZiAoKG5vdCBzZWxmLm5hbWUpCisgICAgICAgICAgICBvciBjYWxsX2Z1bmN0aW9uX3dpdGhfdGFnX2RhdGEKKyAgICAgICAgICAgIG9yIChtYXJrdXAgYW5kIHNlbGYuX21hdGNoZXMobWFya3VwLCBzZWxmLm5hbWUpKQorICAgICAgICAgICAgb3IgKG5vdCBtYXJrdXAgYW5kIHNlbGYuX21hdGNoZXMobWFya3VwX25hbWUsIHNlbGYubmFtZSkpKToKKyAgICAgICAgICAgIGlmIGNhbGxfZnVuY3Rpb25fd2l0aF90YWdfZGF0YToKKyAgICAgICAgICAgICAgICBtYXRjaCA9IHNlbGYubmFtZShtYXJrdXBfbmFtZSwgbWFya3VwX2F0dHJzKQorICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICBtYXRjaCA9IFRydWUKKyAgICAgICAgICAgICAgICBtYXJrdXBfYXR0cl9tYXAgPSBOb25lCisgICAgICAgICAgICAgICAgZm9yIGF0dHIsIG1hdGNoX2FnYWluc3QgaW4gbGlzdChzZWxmLmF0dHJzLml0ZW1zKCkpOgorICAgICAgICAgICAgICAgICAgICBpZiBub3QgbWFya3VwX2F0dHJfbWFwOgorICAgICAgICAgICAgICAgICAgICAgICAgaWYgaGFzYXR0cihtYXJrdXBfYXR0cnMsICdnZXQnKToKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXJrdXBfYXR0cl9tYXAgPSBtYXJrdXBfYXR0cnMKKyAgICAgICAgICAgICAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya3VwX2F0dHJfbWFwID0ge30KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgaywgdiBpbiBtYXJrdXBfYXR0cnM6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hcmt1cF9hdHRyX21hcFtrXSA9IHYKKyAgICAgICAgICAgICAgICAgICAgYXR0cl92YWx1ZSA9IG1hcmt1cF9hdHRyX21hcC5nZXQoYXR0cikKKyAgICAgICAgICAgICAgICAgICAgaWYgbm90IHNlbGYuX21hdGNoZXMoYXR0cl92YWx1ZSwgbWF0Y2hfYWdhaW5zdCk6CisgICAgICAgICAgICAgICAgICAgICAgICBtYXRjaCA9IEZhbHNlCisgICAgICAgICAgICAgICAgICAgICAgICBicmVhaworICAgICAgICAgICAgaWYgbWF0Y2g6CisgICAgICAgICAgICAgICAgaWYgbWFya3VwOgorICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IG1hcmt1cAorICAgICAgICAgICAgICAgIGVsc2U6CisgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gbWFya3VwX25hbWUKKyAgICAgICAgaWYgZm91bmQgYW5kIHNlbGYudGV4dCBhbmQgbm90IHNlbGYuX21hdGNoZXMoZm91bmQuc3RyaW5nLCBzZWxmLnRleHQpOgorICAgICAgICAgICAgZm91bmQgPSBOb25lCisgICAgICAgIHJldHVybiBmb3VuZAorICAgIHNlYXJjaFRhZyA9IHNlYXJjaF90YWcKKworICAgIGRlZiBzZWFyY2goc2VsZiwgbWFya3VwKToKKyAgICAgICAgIyBwcmludCAnbG9va2luZyBmb3IgJXMgaW4gJXMnICUgKHNlbGYsIG1hcmt1cCkKKyAgICAgICAgZm91bmQgPSBOb25lCisgICAgICAgICMgSWYgZ2l2ZW4gYSBsaXN0IG9mIGl0ZW1zLCBzY2FuIGl0IGZvciBhIHRleHQgZWxlbWVudCB0aGF0CisgICAgICAgICMgbWF0Y2hlcy4KKyAgICAgICAgaWYgaGFzYXR0cihtYXJrdXAsICdfX2l0ZXJfXycpIGFuZCBub3QgaXNpbnN0YW5jZShtYXJrdXAsIChUYWcsIGJhc2VzdHJpbmcpKToKKyAgICAgICAgICAgIGZvciBlbGVtZW50IGluIG1hcmt1cDoKKyAgICAgICAgICAgICAgICBpZiBpc2luc3RhbmNlKGVsZW1lbnQsIE5hdmlnYWJsZVN0cmluZykgXAorICAgICAgICAgICAgICAgICAgICAgICBhbmQgc2VsZi5zZWFyY2goZWxlbWVudCk6CisgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gZWxlbWVudAorICAgICAgICAgICAgICAgICAgICBicmVhaworICAgICAgICAjIElmIGl0J3MgYSBUYWcsIG1ha2Ugc3VyZSBpdHMgbmFtZSBvciBhdHRyaWJ1dGVzIG1hdGNoLgorICAgICAgICAjIERvbid0IGJvdGhlciB3aXRoIFRhZ3MgaWYgd2UncmUgc2VhcmNoaW5nIGZvciB0ZXh0LgorICAgICAgICBlbGlmIGlzaW5zdGFuY2UobWFya3VwLCBUYWcpOgorICAgICAgICAgICAgaWYgbm90IHNlbGYudGV4dCBvciBzZWxmLm5hbWUgb3Igc2VsZi5hdHRyczoKKyAgICAgICAgICAgICAgICBmb3VuZCA9IHNlbGYuc2VhcmNoX3RhZyhtYXJrdXApCisgICAgICAgICMgSWYgaXQncyB0ZXh0LCBtYWtlIHN1cmUgdGhlIHRleHQgbWF0Y2hlcy4KKyAgICAgICAgZWxpZiBpc2luc3RhbmNlKG1hcmt1cCwgTmF2aWdhYmxlU3RyaW5nKSBvciBcCisgICAgICAgICAgICAgICAgIGlzaW5zdGFuY2UobWFya3VwLCBiYXNlc3RyaW5nKToKKyAgICAgICAgICAgIGlmIG5vdCBzZWxmLm5hbWUgYW5kIG5vdCBzZWxmLmF0dHJzIGFuZCBzZWxmLl9tYXRjaGVzKG1hcmt1cCwgc2VsZi50ZXh0KToKKyAgICAgICAgICAgICAgICBmb3VuZCA9IG1hcmt1cAorICAgICAgICBlbHNlOgorICAgICAgICAgICAgcmFpc2UgRXhjZXB0aW9uKAorICAgICAgICAgICAgICAgICJJIGRvbid0IGtub3cgaG93IHRvIG1hdGNoIGFnYWluc3QgYSAlcyIgJSBtYXJrdXAuX19jbGFzc19fKQorICAgICAgICByZXR1cm4gZm91bmQKKworICAgIGRlZiBfbWF0Y2hlcyhzZWxmLCBtYXJrdXAsIG1hdGNoX2FnYWluc3QpOgorICAgICAgICAjIHByaW50IHUiTWF0Y2hpbmcgJXMgYWdhaW5zdCAlcyIgJSAobWFya3VwLCBtYXRjaF9hZ2FpbnN0KQorICAgICAgICByZXN1bHQgPSBGYWxzZQorICAgICAgICBpZiBpc2luc3RhbmNlKG1hcmt1cCwgbGlzdCkgb3IgaXNpbnN0YW5jZShtYXJrdXAsIHR1cGxlKToKKyAgICAgICAgICAgICMgVGhpcyBzaG91bGQgb25seSBoYXBwZW4gd2hlbiBzZWFyY2hpbmcgYSBtdWx0aS12YWx1ZWQgYXR0cmlidXRlCisgICAgICAgICAgICAjIGxpa2UgJ2NsYXNzJy4KKyAgICAgICAgICAgIGlmIChpc2luc3RhbmNlKG1hdGNoX2FnYWluc3QsIHVuaWNvZGUpCisgICAgICAgICAgICAgICAgYW5kICcgJyBpbiBtYXRjaF9hZ2FpbnN0KToKKyAgICAgICAgICAgICAgICAjIEEgYml0IG9mIGEgc3BlY2lhbCBjYXNlLiBJZiB0aGV5IHRyeSB0byBtYXRjaCAiZm9vCisgICAgICAgICAgICAgICAgIyBiYXIiIG9uIGEgbXVsdGl2YWx1ZSBhdHRyaWJ1dGUncyB2YWx1ZSwgb25seSBhY2NlcHQKKyAgICAgICAgICAgICAgICAjIHRoZSBsaXRlcmFsIHZhbHVlICJmb28gYmFyIgorICAgICAgICAgICAgICAgICMKKyAgICAgICAgICAgICAgICAjIFhYWCBUaGlzIGlzIGdvaW5nIHRvIGJlIHByZXR0eSBzbG93IGJlY2F1c2Ugd2Uga2VlcAorICAgICAgICAgICAgICAgICMgc3BsaXR0aW5nIG1hdGNoX2FnYWluc3QuIEJ1dCBpdCBzaG91bGRuJ3QgY29tZSB1cAorICAgICAgICAgICAgICAgICMgdG9vIG9mdGVuLgorICAgICAgICAgICAgICAgIHJldHVybiAod2hpdGVzcGFjZV9yZS5zcGxpdChtYXRjaF9hZ2FpbnN0KSA9PSBtYXJrdXApCisgICAgICAgICAgICBlbHNlOgorICAgICAgICAgICAgICAgIGZvciBpdGVtIGluIG1hcmt1cDoKKyAgICAgICAgICAgICAgICAgICAgaWYgc2VsZi5fbWF0Y2hlcyhpdGVtLCBtYXRjaF9hZ2FpbnN0KToKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBUcnVlCisgICAgICAgICAgICAgICAgcmV0dXJuIEZhbHNlCisKKyAgICAgICAgaWYgbWF0Y2hfYWdhaW5zdCBpcyBUcnVlOgorICAgICAgICAgICAgIyBUcnVlIG1hdGNoZXMgYW55IG5vbi1Ob25lIHZhbHVlLgorICAgICAgICAgICAgcmV0dXJuIG1hcmt1cCB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c3NlcnRTb3VwRXF1YWxzKCI8cD4iLCAiPHA+PC9wPiIpCisgICAgICAgIHNlbGYuYXNzZXJ0U291cEVxdWFscygiPGI+IiwgIjxiPjwvYj4iKQorCisgICAgICAgIHNlbGYuYXNzZXJ0U291cEVxdWFscygiPGJyPiIsICI8YnIvPiIpCisKKyAgICBkZWYgdGVzdF9icl9pc19hbHdheXNfZW1wdHlfZWxlbWVudF90YWcoc2VsZik6CisgICAgICAgICIiIkEgPGJyPiB0YWcgaXMgZGVzaWduYXRlZCBhcyBhbiBlbXB0eS1lbGVtZW50IHRhZy4KKworICAgICAgICBTb21lIHBhcnNlcnMgdHJlYXQgPGJyPjwvYnI+IGFzIG9uZSA8YnIvPiB0YWcsIHNvbWUgcGFyc2VycyBhcworICAgICAgICB0d28gdGFncywgYnV0IGl0IHNob3VsZCBhbHdheXMgYmUgYW4gZW1wdHktZWxlbWVudCB0YWcuCisgICAgICAgICIiIgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCI8YnI+PC9icj4iKQorICAgICAgICBzZWxmLmFzc2VydFRydWUoc291cC5ici5pc19lbXB0eV9lbGVtZW50KQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHN0cihzb3VwLmJyKSwgIjxici8+IikKKworICAgIGRlZiB0ZXN0X25lc3RlZF9mb3JtYXR0aW5nX2VsZW1lbnRzKHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydFNvdXBFcXVhbHMoIjxlbT48ZW0+PC9lbT48L2VtPiIpCisKKyAgICBkZWYgdGVzdF9jb21tZW50KHNlbGYpOgorICAgICAgICAjIENvbW1lbnRzIGFyZSByZXByZXNlbnRlZCBhcyBDb21tZW50IG9iamVjdHMuCisgICAgICAgIG1hcmt1cCA9ICI8cD5mb288IS0tZm9vYmFyLS0+YmF6PC9wPiIKKyAgICAgICAgc2VsZi5hc3NlcnRTb3VwRXF1YWxzKG1hcmt1cCkKKworICAgICAgICBzb3VwID0gc2VsZi5zb3VwKG1hcmt1cCkKK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AgICAgICAgc2VsZi5hc3NlcnRTb3VwRXF1YWxzKG5lc3RlZF9iX3RhZykKKworICAgICAgICBkb3VibGVfbmVzdGVkX2JfdGFnID0gIjxwPkEgPGE+ZG91Ymx5IDxpPm5lc3RlZCA8Yj50YWc8L2I+PC9pPjwvYT48L3A+IgorICAgICAgICBzZWxmLmFzc2VydFNvdXBFcXVhbHMobmVzdGVkX2JfdGFnKQorCisgICAgZGVmIHRlc3RfbmVzdGVkX2Jsb2NrX2xldmVsX2VsZW1lbnRzKHNlbGYpOgorICAgICAgICAiIiJCbG9jayBlbGVtZW50cyBjYW4gYmUgbmVzdGVkLiIiIgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCc8YmxvY2txdW90ZT48cD48Yj5Gb288L2I+PC9wPjwvYmxvY2txdW90ZT4nKQorICAgICAgICBibG9ja3F1b3RlID0gc291cC5ibG9ja3F1b3RlCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoYmxvY2txdW90ZS5wLmIuc3RyaW5nLCAnRm9vJykKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChibG9ja3F1b3RlLmIuc3RyaW5nLCAnRm9vJykKKworICAgIGRlZiB0ZXN0X2NvcnJlY3RseV9uZXN0ZWRfdGFibGVzKHNlbGYpOgorICAgICAgICAiIiJPbmUgdGFibGUgY2FuIGdvIGluc2lkZSBhbm90aGVyIG9uZS4iIiIKKyAgICAgICAgbWFya3VwID0gKCc8dGFibGUgaWQ9IjEiPicKKyAgICAgICAgICAgICAgICAgICc8dHI+JworICAgICAgICAgICAgICAgICAgIjx0ZD5IZXJlJ3MgYW5vdGhlciB0YWJsZToiCisgICAgICAgICAgICAgICAgICAnPHRhYmxlIGlkPSIyIj4nCisgICAgICAgICAgICAgICAgICAnPHRyPjx0ZD5mb288L3RkPjwvdHI+JworICAgICAgICAgICAgICAgICAgJzwvdGFibGU+PC90ZD4nKQorCisgICAgICAgIHNlbGYuYXNzZXJ0U291cEVxdWFscygKKyAgICAgICA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ICgKKyAgICAgICAgTFhNTFRyZWVCdWlsZGVyRm9yWE1MLAorICAgICAgICBMWE1MVHJlZUJ1aWxkZXIsCisgICAgICAgICkKKyAgICBMWE1MX1BSRVNFTlQgPSBUcnVlCitleGNlcHQgSW1wb3J0RXJyb3I6CisgICAgTFhNTF9QUkVTRU5UID0gRmFsc2UKKworCitjbGFzcyBCdWlsdEluUmVnaXN0cnlUZXN0KHVuaXR0ZXN0LlRlc3RDYXNlKToKKyAgICAiIiJUZXN0IHRoZSBidWlsdC1pbiByZWdpc3RyeSB3aXRoIHRoZSBkZWZhdWx0IGJ1aWxkZXJzIHJlZ2lzdGVyZWQuIiIiCisKKyAgICBkZWYgdGVzdF9jb21iaW5hdGlvbihzZWxmKToKKyAgICAgICAgaWYgTFhNTF9QUkVTRU5UOgorICAgICAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChyZWdpc3RyeS5sb29rdXAoJ2Zhc3QnLCAnaHRtbCcpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMWE1MVHJlZUJ1aWxkZXIpCisKKyAgICAgICAgaWYgTFhNTF9QUkVTRU5UOgorICAgICAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChyZWdpc3RyeS5sb29rdXAoJ3Blcm1pc3NpdmUnLCAneG1sJyksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExYTUxUcmVlQnVpbGRlckZvclhNTCkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChyZWdpc3RyeS5sb29rdXAoJ3N0cmljdCcsICdodG1sJyksCisgICAgICAgICAgICAgICAgICAgICAgICAgIEhUTUxQYXJzZXJUcmVlQnVpbGRlcikKKyAgICAgICAgaWYgSFRNTDVMSUJfUFJFU0VOVDoKKyAgICAgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwocmVnaXN0cnkubG9va3VwKCdodG1sNWxpYicsICdodG1sJyksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBIVE1MNVRyZWVCdWlsZGVyKQ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ikKKyAgICAgICAgbWFya3VwID0gIjxwPkEgPGI+Ym9sZDwvYj4gc3RhdGVtZW50LjwvcD4iCisgICAgICAgIHdpdGggd2FybmluZ3MuY2F0Y2hfd2FybmluZ3MocmVjb3JkPVRydWUpIGFzIHc6CisgICAgICAgICAgICBzb3VwID0gc2VsZi5zb3VwKG1hcmt1cCwgcGFyc2Vfb25seT1zdHJhaW5lcikKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCgKKyAgICAgICAgICAgIHNvdXAuZGVjb2RlKCksIHNlbGYuZG9jdW1lbnRfZm9yKG1hcmt1cCkpCisKKyAgICAgICAgc2VsZi5hc3NlcnRUcnVlKAorICAgICAgICAgICAgInRoZSBodG1sNWxpYiB0cmVlIGJ1aWxkZXIgZG9lc24ndCBzdXBwb3J0IHBhcnNlX29ubHkiIGluCisgICAgICAgICAgICBzdHIod1swXS5tZXNzYWdlKSkKKworICAgIGRlZiB0ZXN0X2NvcnJlY3RseV9uZXN0ZWRfdGFibGVzKHNlbGYpOgorICAgICAgICAiIiJodG1sNWxpYiBpbnNlcnRzIDx0Ym9keT4gdGFncyB3aGVyZSBvdGhlciBwYXJzZXJzIGRvbid0LiIiIgorICAgICAgICBtYXJrdXAgPSAoJzx0YWJsZSBpZD0iMSI+JworICAgICAgICAgICAgICAgICAgJzx0cj4nCisgICAgICAgICAgICAgICAgICAiPHRkPkhlcmUncyBhbm90aGVyIHRhYmxlOiIKKyAgICAgICAgICAgICAgICAgICc8dGFibGUgaWQ9IjIiPicKKyAgICAgICAgICAgICAgICAgICc8dHI+PHRkPmZvbzwvdGQ+PC90cj4nCisgICAgICAgICAgICAgICAgICAnPC90YWJsZT48L3RkPicpCisKKyAgICAgICAgc2VsZi5hc3NlcnRTb3VwRXF1YWxzKAorICAgICAgICAgICAgbWFya3VwLAorICAgICAgICAgICAgJzx0YWJsZSBpZD0iMSI+PHRib2R5Pjx0cj48dGQ+SGVyZVwncyBhbm90aGVyIHRhYmxlOicKKyAgICAgICAg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GYuYXNzZXJ0RXF1YWwoc2VsZi5zdWIuc3Vic3RpdHV0ZV9odG1sKGRhbW1pdC5tYXJrdXApLAorICAgICAgICAgICAgICAgICAgICAgICAgICAiJmxzcXVvOyZyc3F1bztmb28mbGRxdW87JnJkcXVvOyIpCisKKyAgICBkZWYgdGVzdF94bWxfY29udmVyc3Rpb25faW5jbHVkZXNfbm9fcXVvdGVzX2lmX21ha2VfcXVvdGVkX2F0dHJpYnV0ZV9pc19mYWxzZShzZWxmKToKKyAgICAgICAgcyA9ICdXZWxjb21lIHRvICJteSBiYXIiJworICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNlbGYuc3ViLnN1YnN0aXR1dGVfeG1sKHMsIEZhbHNlKSwgcykKKworICAgIGRlZiB0ZXN0X3htbF9hdHRyaWJ1dGVfcXVvdGluZ19ub3JtYWxseV91c2VzX2RvdWJsZV9xdW90ZXMoc2VsZik6CisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc2VsZi5zdWIuc3Vic3RpdHV0ZV94bWwoIldlbGNvbWUiLCBUcnVlKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgJyJXZWxjb21lIicpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc2VsZi5zdWIuc3Vic3RpdHV0ZV94bWwoIkJvYidzIEJhciIsIFRydWUpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAnIkJvYlwncyBCYXIiJykKKworICAgIGRlZiB0ZXN0X3htbF9hdHRyaWJ1dGVfcXVvdGluZ191c2VzX3NpbmdsZV9xdW90ZXNfd2hlbl92YWx1ZV9jb250YWluc19kb3VibGVfcXVvdGVzKHNlbGYpOgorICAgICAgICBzID0gJ1dlbGNvbWUgdG8gIm15IGJhciInCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc2VsZi5zdWIuc3Vic3RpdHV0ZV94bWwocywgVHJ1ZSksCisgICAgICAgICAgICAgICAgICAgICAgICAgICInV2VsY29tZSB0byBcIm15IGJhclwiJ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orICAgICAgICAjIFlvdSBjYW4gcGFzcyBpbiBhIGRpY3Rpb25hcnkgYXMgdGhlIGFyZ3VtZW50ICdhdHRycycuIFRoaXMKKyAgICAgICAgIyBsZXRzIHlvdSBzZWFyY2ggZm9yIGF0dHJpYnV0ZXMgbGlrZSAnbmFtZScgKGEgZml4ZWQgYXJndW1lbnQKKyAgICAgICAgIyB0byBmaW5kX2FsbCkgYW5kICdjbGFzcycgKGEgcmVzZXJ2ZWQgd29yZCBpbiBQeXRob24uKQorICAgICAgICB0cmVlID0gc2VsZi5zb3VwKCIiIgorICAgICAgICAgICAgICAgICAgICAgICAgIDxhIG5hbWU9Im5hbWUxIiBjbGFzcz0iY2xhc3MxIj5OYW1lIG1hdGNoLjwvYT4KKyAgICAgICAgICAgICAgICAgICAgICAgICA8YSBuYW1lPSJuYW1lMiIgY2xhc3M9ImNsYXNzMiI+Q2xhc3MgbWF0Y2guPC9hPgorICAgICAgICAgICAgICAgICAgICAgICAgIDxhIG5hbWU9Im5hbWUzIiBjbGFzcz0iY2xhc3MzIj5Ob24tbWF0Y2guPC9hPgorICAgICAgICAgICAgICAgICAgICAgICAgIDxuYW1lMT5BIHRhZyBjYWxsZWQgJ25hbWUxJy48L25hbWUxPgorICAgICAgICAgICAgICAgICAgICAgICAgICIiIikKKworICAgICAgICAjIFRoaXMgZG9lc24ndCBkbyB3aGF0IHlvdSB3YW50LgorICAgICAgICBzZWxmLmFzc2VydFNlbGVjdHModHJlZS5maW5kX2FsbChuYW1lPSduYW1lMScpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgWyJBIHRhZyBjYWxsZWQgJ25hbWUxJy4iXSkKKyAgICAgICAgIyBUaGlzIGRvZXMgd2hhdCB5b3Ugd2FudC4KKyAgICAgICAgc2VsZi5hc3NlcnRTZWxlY3RzKHRyZWUuZmluZF9hbGwoYXR0cnM9eyduYW1lJyA6ICduYW1lMSd9KSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgIFsiTmFtZSBtYXRjaC4iXSkKKworICAgICAgICBzZWxmLmFzc2VydFNlbGVjdHModHJlZS5maW5kX2FsbChhdHRycz17J2NsYXNzJyA6ICdjbGFzczInfSksCisgICAgICAgICAgICAgICAgICAgICAgICAgICBbIkNsYXNzIG1hdGNoLiJdKQorCisgICAgZGVmIHRlc3RfZmluZF9hbGxfYnlfY2xhc3Moc2VsZik6CisgICAgICAgIHRyZWUgPSBzZWxmLnNvdXAoIiIiCisgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9IjEiPkNsYXNzIDEuPC9hPgorICAgICAgICAgICAgICAgICAgICAgICAgIDxhIGNsYXNzPSIyIj5DbGFzcyAyLjwvYT4KKyAgICAgICAgICAgICAgICAgICAgICAgICA8YiBjbGFzcz0iMSI+Q2xhc3MgMS48L2I+CisgICAgICAgICAgICAgICAgICAgICAgICAgPGMgY2xhc3M9IjMgNCI+Q2xhc3MgMyBhbmQgNC48L2M+CisgICAgICAgICAgICAgICAgICAgICAgICAgIiIiKQorCisgICAgICAgICMgUGFzc2luZyBpbiB0aGUgY2xhc3NfIGtleXdvcmQgYXJndW1lbnQgd2lsbCBzZWFyY2ggYWdhaW5zdAorICAgICAgICAjIHRoZSAnY2xhc3MnIGF0dHJpYnV0ZS4KKyAgICAgICAgc2VsZi5hc3NlcnRTZWxlY3RzKHRyZWUuZmluZF9hbGwoJ2EnLCBjbGFzc189JzEnKSwgWydDbGFzcyAxLiddKQorICAgICAgICBzZWxmLmFzc2VydFNlbGVjdHModHJlZS5maW5kX2FsbCgnYycsIGNsYXNzXz0nMycpLCBbJ0NsYXNzIDMgYW5kIDQuJ10pCisgICAgICAgIHNlbGYuYXNzZXJ0U2VsZWN0cyh0cmVlLmZpbmRfYWxsKCdjJywgY2xhc3NfPSc0JyksIFsnQ2xhc3MgMyBhbmQgNC4nXSkKKworICAgICAgICAjIFBhc3NpbmcgaW4gYSBzdHJpbmcgdG8gJ2F0dHJzJyB3aWxsIGFsc28gc2VhcmNoIHRoZSBDU1M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AgICAgICAgICAgICBbIjEiLCAiMyJdKQorCisgICAgZGVmIHRlc3RfZmluZF9hbGxfd2l0aF9yZWd1bGFyX2V4cHJlc3Npb25fYXR0cmlidXRlX3ZhbHVlKHNlbGYpOgorICAgICAgICAjIFlvdSBjYW4gcGFzcyBhIHJlZ3VsYXIgZXhwcmVzc2lvbiBhcyBhbiBhdHRyaWJ1dGUgdmFsdWUsIGFuZAorICAgICAgICAjIHlvdSdsbCBnZXQgdGFncyB3aG9zZSB2YWx1ZXMgZm9yIHRoYXQgYXR0cmlidXRlIG1hdGNoIHRoZQorICAgICAgICAjIHJlZ3VsYXIgZXhwcmVzc2lvbi4KKyAgICAgICAgdHJlZSA9IHNlbGYuc291cCgiIiI8YSBpZD0iYSI+T25lIGEuPC9hPgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxhIGlkPSJhYSI+VHdvIGFzLjwvYT4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBpZD0iYWIiPk1peGVkIGFzIGFuZCBicy48L2E+CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgaWQ9ImIiPk9uZSBiLjwvYT4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YT5ObyBJRC48L2E+IiIiKQorCisgICAgICAgIHNlbGYuYXNzZXJ0U2VsZWN0cyh0cmVlLmZpbmRfYWxsKGlkPXJlLmNvbXBpbGUoIl5hKyQiKSksCisgICAgICAgICAgICAgICAgICAgICAgICAgICBbIk9uZSBhLiIsICJUd28gYXMuIl0pCisKKyAgICBkZWYgdGVzdF9maW5kX2J5X25hbWVfYW5kX2NvbnRhaW5pbmdfc3RyaW5nKHNlbGYpOgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCI8Yj5mb288L2I+PGI+YmFyPC9iPjxhPmZvbzwvYT4iKQorICAgICAgICBhID0gc291cC5hCisKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChbYV0sIHNvdXAuZmluZF9hbGwoImEiLCB0ZXh0PSJmb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pY2FsPC9iPgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxhPklkZW50aWNhbDwvYT4KKworICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxjPjxkPklkZW50aWNhbCB3aXRoIGNoaWxkPC9kPjwvYz4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICA8Yj5BbHNvIG5vdCBpZGVudGljYWw8L2I+CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGM+PGQ+SWRlbnRpY2FsIHdpdGggY2hpbGQ8L2Q+PC9jPgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIDwvZGl2PiIiIikKKyAgICAgICAgZGl2ID0gdHJlZS5kaXYKKyAgICAgICAgZm9yIGksIGVsZW1lbnQgaW4gZW51bWVyYXRlKGRpdi5jb250ZW50cyk6CisgICAgICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGksIGRpdi5pbmRleChlbGVtZW50KSkKKyAgICAgICAgc2VsZi5hc3NlcnRSYWlzZXMoVmFsdWVFcnJvciwgdHJlZS5pbmRleCwgMSkKKworCitjbGFzcyBUZXN0UGFyZW50T3BlcmF0aW9ucyhUcmVlVGVzdCk6CisgICAgIiIiVGVzdCBuYXZpZ2F0aW9uIGFuZCBzZWFyY2hpbmcgdGhyb3VnaCBhbiBlbGVtZW50J3MgcGFyZW50cy4iIiIKKworICAgIGRlZiBzZXRVcChzZWxmKToKKyAgICAgICAgc3VwZXIoVGVzdFBhcmVudE9wZXJhdGlvbnMsIHNlbGYpLnNldFVwKCkKKyAgICAgICAgc2VsZi50cmVlID0gc2VsZi5zb3VwKCcnJzx1bCBpZD0iZW1wdHkiPjwvdWw+CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8dWwgaWQ9InRvcCI+CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPHVsIGlkPSJtaWRkbGUiPgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8dWwgaWQ9ImJvdHRvbSI+CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8Yj5TdGFydCBoZXJlPC9iPgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8L3VsPgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDwvdWw+JycnKQorICAgICAgICBzZWxmLnN0YXJ0ID0gc2VsZi50cmVlLmIKKworCisgICAgZGVmIHRlc3RfcGFyZW50KHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNlbGYuc3RhcnQucGFyZW50WydpZCddLCAnYm90dG9tJykKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChzZWxmLnN0YXJ0LnBhcmVudC5wYXJlbnRbJ2lkJ10sICdtaWRkbGUnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNlbGYuc3RhcnQucGFyZW50LnBhcmVudC5wYXJlbnRbJ2lkJ10sICd0b3AnKQorCisgICAgZGVmIHRlc3RfcGFyZW50X29mX3RvcF90YWdfaXNfc291cF9vYmplY3Qoc2VsZik6CisgICAgICAgIHRvcF90YWcgPSBzZWxmLnRyZWUuY29udGVudHNbMF0KKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCh0b3BfdGFnLnBhcmVudCwgc2VsZi50cmVlKQorCisgICAgZGVmIHRlc3Rfc291cF9vYmplY3RfaGFzX25vX3BhcmVudChzZWxmKToKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChOb25lLCBzZWxmLnRyZWUucGFyZW50KQorCisgICAgZGVmIHRlc3RfZmluZF9wYXJlbnRzKHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydFNlbGVjdHNJRHMoCisgICAgICAgICAgICBzZWxmLnN0YXJ0LmZpbmRfcGFyZW50cygndWwnKSwgWydib3R0b20nLCAnbWlkZGxlJywgJ3RvcCddKQorICAgICAgICBzZWxmLmFzc2VydFNlbGVjdHNJRHMoCisgICAgICAgICAgICBzZWxmLnN0YXJ0LmZpbmRfcGFyZW50cygndWwnLCBpZD0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HN1Y2Nlc3NvcnMKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCh0YWdbJ2lkJ10sICczJykKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChjb250ZW50cywgIlRocmVlIikKKworY2xhc3MgVGVzdFByZXZpb3VzT3BlcmF0aW9ucyhQcm94aW1pdHlUZXN0KToKKworICAgIGRlZiBzZXRVcChzZWxmKToKKyAgICAgICAgc3VwZXIoVGVzdFByZXZpb3VzT3BlcmF0aW9ucywgc2VsZikuc2V0VXAoKQorICAgICAgICBzZWxmLmVuZCA9IHNlbGYudHJlZS5maW5kKHRleHQ9IlRocmVlIikKKworICAgIGRlZiB0ZXN0X3ByZXZpb3VzKHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNlbGYuZW5kLnByZXZpb3VzX2VsZW1lbnRbJ2lkJ10sICIzIikKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChzZWxmLmVuZC5wcmV2aW91c19lbGVtZW50LnByZXZpb3VzX2VsZW1lbnQsICJUd28iKQorCisgICAgZGVmIHRlc3RfcHJldmlvdXNfb2ZfZmlyc3RfaXRlbV9pc19ub25lKHNlbGYpOgorICAgICAgICBmaXJzdCA9IHNlbGYudHJlZS5maW5kKCdodG1sJykKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChmaXJzdC5wcmV2aW91c19lbGVtZW50LCBOb25lKQorCisgICAgZGVmIHRlc3RfcHJldmlvdXNfb2Zfcm9vdF9pc19ub25lKHNlbGYpOgorICAgICAgICAjIFRoZSBkb2N1bWVudCByb290IGlzIG91dHNpZGUgdGhlIG5leHQvcHJldmlvdXMgY2hhaW4uCisgICAgICAgICMgWFhYIFRoaXMgaXMgYnJva2VuIQorICAgICAgICAjc2VsZi5hc3NlcnRFcXVhbChzZWxmLnRyZWUucHJldmlvdXNfZWxlbWVudCwgTm9uZSkKKyAgICAgICAgcGFzcworCisgICAgZGVmIHRlc3RfZmluZF9hbGxfcHJldmlvdXMoc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Xh0PSJPbmUiKQorICAgICAgICBwcmVkZWNlc3NvcnMgPSBbbm9kZSBmb3Igbm9kZSBpbiBzdGFydC5wcmV2aW91c19lbGVtZW50c10KKworICAgICAgICAjIFRoZXJlIGFyZSBmb3VyIHByZWRlY2Vzc29yczogdGhlIDxiPiB0YWcgY29udGFpbmluZyAiT25lIgorICAgICAgICAjIHRoZSA8Ym9keT4gdGFnLCB0aGUgPGhlYWQ+IHRhZywgYW5kIHRoZSA8aHRtbD4gdGFnLgorICAgICAgICBiLCBib2R5LCBoZWFkLCBodG1sID0gcHJlZGVjZXNzb3JzCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoYlsnaWQnXSwgJzEnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGJvZHkubmFtZSwgImJvZHkiKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGhlYWQubmFtZSwgImhlYWQiKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGh0bWwubmFtZSwgImh0bWwiKQorCisKK2NsYXNzIFNpYmxpbmdUZXN0KFRyZWVUZXN0KToKKworICAgIGRlZiBzZXRVcChzZWxmKToKKyAgICAgICAgc3VwZXIoU2libGluZ1Rlc3QsIHNlbGYpLnNldFVwKCkKKyAgICAgICAgbWFya3VwID0gJycnPGh0bWw+CisgICAgICAgICAgICAgICAgICAgIDxzcGFuIGlkPSIxIj4KKyAgICAgICAgICAgICAgICAgICAgIDxzcGFuIGlkPSIxLjEiPjwvc3Bhbj4KKyAgICAgICAgICAgICAgICAgICAgPC9zcGFuPgorICAgICAgICAgICAgICAgICAgICA8c3BhbiBpZD0iMiI+CisgICAgICAgICAgICAgICAgICAgICA8c3BhbiBpZD0iMi4xIj48L3NwYW4+CisgICAgICAgICAgICAgICAgICAgIDwvc3Bhbj4KKyAgICAgICAgICAgICAgICAgICAgPHNwYW4gaWQ9IjMiPgorICAgICAgICAgICAgICAgICAgICAgPHNwYW4gaWQ9IjMuMSI+PC9zcGFuPgorICAgICAgIC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Xh0X2VsZW1lbnRbJ2lkJ10sICcxLjEnKQorCisgICAgZGVmIHRlc3RfbmV4dF9zaWJsaW5nX21heV9ub3RfZXhpc3Qoc2VsZik6CisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc2VsZi50cmVlLmh0bWwubmV4dF9zaWJsaW5nLCBOb25lKQorCisgICAgICAgIG5lc3RlZF9zcGFuID0gc2VsZi50cmVlLmZpbmQoaWQ9IjEuMSIpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobmVzdGVkX3NwYW4ubmV4dF9zaWJsaW5nLCBOb25lKQorCisgICAgICAgIGxhc3Rfc3BhbiA9IHNlbGYudHJlZS5maW5kKGlkPSI0IikKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChsYXN0X3NwYW4ubmV4dF9zaWJsaW5nLCBOb25lKQorCisgICAgZGVmIHRlc3RfZmluZF9uZXh0X3NpYmxpbmcoc2VsZik6CisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc2VsZi5zdGFydC5maW5kX25leHRfc2libGluZygnc3BhbicpWydpZCddLCAnMicpCisKKyAgICBkZWYgdGVzdF9uZXh0X3NpYmxpbmdzKHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydFNlbGVjdHNJRHMoc2VsZi5zdGFydC5maW5kX25leHRfc2libGluZ3MoInNwYW4iKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFsnMicsICczJywgJzQnXSkKKworICAgICAgICBzZWxmLmFzc2VydFNlbGVjdHNJRHMoc2VsZi5zdGFydC5maW5kX25leHRfc2libGluZ3MoaWQ9JzMnKSwgWyczJ10pCisKKyAgICBkZWYgdGVzdF9uZXh0X3NpYmxpbmdfZm9yX3RleHRfZWxlbWVudChzZWxmKToKKyAgICAgICAgc291cCA9IHNlbGYuc291cCgiRm9vPGI+YmFyPC9iPmJheiIpCisgICAgICAgIHN0YXJ0ID0gc291cC5maW5kKHRleHQ9IkZvbyIpCisgICAgICAgIHNlbGYuY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ChiIjxwPjwvcD4iLCBodG1sX3AuZW5jb2RlKCkpCisKKyAgICBkZWYgdGVzdF9uZXdfc3RyaW5nX2NyZWF0ZXNfbmF2aWdhYmxlc3RyaW5nKHNlbGYpOgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCIiKQorICAgICAgICBzID0gc291cC5uZXdfc3RyaW5nKCJmb28iKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKCJmb28iLCBzKQorICAgICAgICBzZWxmLmFzc2VydFRydWUoaXNpbnN0YW5jZShzLCBOYXZpZ2FibGVTdHJpbmcpKQorCisgICAgZGVmIHRlc3RfbmV3X3N0cmluZ19jYW5fY3JlYXRlX25hdmlnYWJsZXN0cmluZ19zdWJjbGFzcyhzZWxmKToKKyAgICAgICAgc291cCA9IHNlbGYuc291cCgiIikKKyAgICAgICAgcyA9IHNvdXAubmV3X3N0cmluZygiZm9vIiwgQ29tbWVudCkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCgiZm9vIiwgcykKKyAgICAgICAgc2VsZi5hc3NlcnRUcnVlKGlzaW5zdGFuY2UocywgQ29tbWVudCkpCisKK2NsYXNzIFRlc3RUcmVlTW9kaWZpY2F0aW9uKFNvdXBUZXN0KToKKworICAgIGRlZiB0ZXN0X2F0dHJpYnV0ZV9tb2RpZmljYXRpb24oc2VsZik6CisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoJzxhIGlkPSIxIj48L2E+JykKKyAgICAgICAgc291cC5hWydpZCddID0gMgorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNvdXAuZGVjb2RlKCksIHNlbGYuZG9jdW1lbnRfZm9yKCc8YSBpZD0iMiI+PC9hPicpKQorICAgICAgICBkZWwoc291cC5hWydpZCddKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNvdXAuZGVjb2RlKCksIHNlbGYuZG9jdW1lbnRfZm9yKCc8YT48L2E+JykpCisgICAgICAgIHNvdXAuYVsnaWQyJ10gPSAnZm9vJworICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNvdXAuZGVjb2RlKCksIHNlbGYuZG9jdW1lbnRfZm9yKCc8YSBpZDI9ImZvbyI+PC9hPicpKQorCisgICAgZGVmIHRlc3RfbmV3X3RhZ19jcmVhdGlvbihzZWxmKToKKyAgICAgICAgYnVpbGRlciA9IGJ1aWxkZXJfcmVnaXN0cnkubG9va3VwKCdodG1sJykoKQorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCI8Ym9keT48L2JvZHk+IiwgYnVpbGRlcj1idWlsZGVyKQorICAgICAgICBhID0gVGFnKHNvdXAsIGJ1aWxkZXIsICdhJykKKyAgICAgICAgb2wgPSBUYWcoc291cCwgYnVpbGRlciwgJ29sJykKKyAgICAgICAgYVsnaHJlZiddID0gJ2h0dHA6Ly9mb28uY29tLycKKyAgICAgICAgc291cC5ib2R5Lmluc2VydCgwLCBhKQorICAgICAgICBzb3VwLmJvZHkuaW5zZXJ0KDEsIG9sKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKAorICAgICAgICAgICAgc291cC5ib2R5LmVuY29kZSgpLAorICAgICAgICAgICAgYic8Ym9keT48YSBocmVmPSJodHRwOi8vZm9vLmNvbS8iPjwvYT48b2w+PC9vbD48L2JvZHk+JykKKworICAgIGRlZiB0ZXN0X2FwcGVuZF90b19jb250ZW50c19tb3Zlc190YWcoc2VsZik6CisgICAgICAgIGRvYyA9ICIiIjxwIGlkPSIxIj5Eb24ndCBsZWF2ZSBtZSA8Yj5oZXJlPC9iPi48L3A+CisgICAgICAgICAgICAgICAgPHAgaWQ9IjIiPkRvblwndCBsZWF2ZSE8L3A+IiIiCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoZG9jKQorICAgICAgICBzZWNvbmRfcGFyYSA9IHNvdXAuZmluZChpZD0nMicpCisgICAgICAgIGJvbGQgPSBzb3VwLmIKKworICAgICAgICAjIE1vdmUgdGhlIDxiPiB0YWcgdG8gdGhlIGVuZCBvZiB0aGUgc2Vjb25kIHBhcmFncmFwaC4KKyAgICAgICAgc291cC5maW5kKGlkPScyJykuYXBwZW5kKHNvdXAuYikKKworICAgICAgICAjIFRoZSA8Yj4gdGFnIGlzIG5vdyBhIGNoaWxkIG9mIHRoZSBzZWNvbmQgcGFyYWdyYXBoLgorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGJvbGQucGFyZW50LCBzZWNvbmRfcGFyYSkKKworICAgICAgICBzZWxmLmFzc2VydEVxdWFsKAorICAgICAgICAgICAgc291cC5kZWNvZGUoKSwgc2VsZi5kb2N1bWVudF9mb3IoCisgICAgICAgICAgICAgICAgJzxwIGlkPSIxIj5Eb25cJ3QgbGVhdmUgbWUgLjwvcD5cbicKKyAgICAgICAgICAgICAgICAnPHAgaWQ9IjIiPkRvblwndCBsZWF2ZSE8Yj5oZXJlPC9iPjwvcD4nKSkKKworICAgIGRlZiB0ZXN0X3JlcGxhY2Vfd2l0aF9yZXR1cm5zX3RoaW5nX3RoYXRfd2FzX3JlcGxhY2VkKHNlbGYpOgorICAgICAgICB0ZXh0ID0gIjxhPjwvYT48Yj48Yz48L2M+PC9iPiIKKyAgICAgICAgc291cCA9IHNlbGYuc291cCh0ZXh0KQorICAgICAgICBhID0gc291cC5hCisgICAgICAgIG5ld19hID0gYS5yZXBsYWNlX3dpdGgoc291cC5jKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGEsIG5ld19hKQorCisgICAgZGVmIHRlc3RfdW53cmFwX3JldHVybnNfdGhpbmdfdGhhdF93YXNfcmVwbGFjZWQoc2VsZik6CisgICAgICAgIHRleHQgPSAiPGE+PGI+PC9iPjxjPjwvYz48L2E+IgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKHRleHQpCisgICAgICAgIGEgPSBzb3VwLmEKKyAgICAgICAgbmV3X2EgPSBhLnVud3JhcCgpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoYSwgbmV3X2EpCisKKyAgICBkZWYgdGVzdF9yZXBsYWNlX3RhZ193aXRoX2l0c2VsZihzZWxmKToKKyAgICAgICAgdGV4dCA9ICI8YT48Yj48L2I+PGM+Rm9vPGQ+PC9kPjwvYz48L2E+PGE+PGU+PC9lPjwvYT4iCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAodGV4dCkKKyAgICAgICAgYyA9IHNvdXAuYworICAgICAgICBzb3VwLmMucmVwbGFjZV93aXRoKGMpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc291cC5kZWNvZGUoKSwgc2VsZi5kb2N1bWVudF9mb3IodGV4dCkpCisKKyAgICBkZWYgdGVzdF9yZXBsYWNlX3RhZ193aXRoX2l0c19wYXJlbnRfcmFpc2VzX2V4Y2VwdGlvbihzZWxmKToKKyAgICAgICAgdGV4dCA9ICI8YT48Yj48L2I+PC9hPiIKKyAgICAgICAgc291cCA9IHNlbGYuc291cCh0ZXh0KQorICAgICAgICBzZWxmLmFzc2VydFJhaXNlcyhWYWx1ZUVycm9yLCBzb3VwLmIucmVwbGFjZV93aXRoLCBzb3VwLmEpCisKKyAgICBkZWYgdGVzdF9pbnNlcnRfdGFnX2ludG9faXRzZWxmX3JhaXNlc19leGNlcHRpb24oc2VsZik6CisgICAgICAgIHRleHQgPSAiPGE+PGI+PC9iPjwvYT4iCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAodGV4dCkKKyAgICAgICAgc2VsZi5hc3NlcnRSYWlzZXMoVmFsdWVFcnJvciwgc291cC5hLmluc2VydCwgMCwgc291cC5hKQorCisgICAgZGVmIHRlc3RfcmVwbGFjZV93aXRoX21haW50YWluc19uZXh0X2VsZW1lbnRfdGhyb3VnaG91dChzZWxmKToKKyAgICAgICAgc291cCA9IHNlbGYuc291cCgnPHA+PGE+b25lPC9hPjxiPnRocmVlPC9iPjwvcD4nKQorICAgICAgICBhID0gc291cC5hCisgICAgICAgIGIgPSBhLmNvbnRlbnRzWzBdCisgICAgICAgICMgTWFrZSBpdCBzbyB0aGUgPGE+IHRhZyBoYXMgdHdvIHRleHQg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4dCBub2RlcywKKyAgICAgICAgIyBidXQgaWYgeW91IGluc2VydCBvbmUgbmV4dCB0byBhbm90aGVyLCBCZWF1dGlmdWwgU291cCB3aWxsCisgICAgICAgICMgaGFuZGxlIGl0IGNvcnJlY3RseS4KKyAgICAgICAgc291cCA9IHNlbGYuc291cCgiPGE+PGI+QXJnaCE8L2I+PGM+PC9jPjwvYT4iKQorICAgICAgICBzb3VwLmIuaW5zZXJ0KDEsICJIb29yYXkhIikKKworICAgICAgICBzZWxmLmFzc2VydEVxdWFsKAorICAgICAgICAgICAgc291cC5kZWNvZGUoKSwgc2VsZi5kb2N1bWVudF9mb3IoCisgICAgICAgICAgICAgICAgIjxhPjxiPkFyZ2ghSG9vcmF5ITwvYj48Yz48L2M+PC9hPiIpKQorCisgICAgICAgIG5ld190ZXh0ID0gc291cC5maW5kKHRleHQ9Ikhvb3JheSEiKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKG5ld190ZXh0LnByZXZpb3VzX2VsZW1lbnQsICJBcmdoISIpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobmV3X3RleHQucHJldmlvdXNfZWxlbWVudC5uZXh0X2VsZW1lbnQsIG5ld190ZXh0KQorCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobmV3X3RleHQucHJldmlvdXNfc2libGluZywgIkFyZ2ghIikKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChuZXdfdGV4dC5wcmV2aW91c19zaWJsaW5nLm5leHRfc2libGluZywgbmV3X3RleHQpCisKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChuZXdfdGV4dC5uZXh0X3NpYmxpbmcsIE5vbmUpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobmV3X3RleHQubmV4dF9lbGVtZW50LCBzb3VwLmMpCisKKyAgICBkZWYgdGVzdF9pbnNlcnRfc3RyaW5nKHNlbGYpOgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCI8YT48L2E+IikKKyAgICAgICAgc291cC5hLmluc2VydCgwLCAiYmFyIikKKyAgICAgICAgc291cC5hLmluc2VydCgwLCAiZm9vIikKKyAgICAgICAgIyBUaGUgc3RyaW5nIHdlcmUgYWRkZWQgdG8gdGhlIHRhZy4KKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChbImZvbyIsICJiYXIiXSwgc291cC5hLmNvbnRlbnRzKQorICAgICAgICAjIEFuZCB0aGV5IHdlcmUgY29udmVydGVkIHRvIE5hdmlnYWJsZVN0cmluZ3MuCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc291cC5hLmNvbnRlbnRzWzBdLm5leHRfZWxlbWVudCwgImJhciIpCisKKyAgICBkZWYgdGVzdF9pbnNlcnRfdGFnKHNlbGYpOgorICAgICAgICBidWlsZGVyID0gc2VsZi5kZWZhdWx0X2J1aWxkZXIKKyAgICAgICAgc291cCA9IHNlbGYuc291cCgKKyAgICAgICAgICAgICI8YT48Yj5GaW5kPC9iPjxjPmxhZHkhPC9jPjxkPjwvZD48L2E+IiwgYnVpbGRlcj1idWlsZGVyKQorICAgICAgICBtYWdpY190YWcgPSBUYWcoc291cCwgYnVpbGRlciwgJ21hZ2ljdGFnJykKKyAgICAgICAgbWFnaWNfdGFnLmluc2VydCgwLCAidGhlIikKKyAgICAgICAgc291cC5hLmluc2VydCgxLCBtYWdpY190YWcpCisKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCgKKyAgICAgICAgICAgIHNvdXAuZGVjb2RlKCksIHNlbGYuZG9jdW1lbnRfZm9yKAorICAgICAgICAgICAgICAgICI8YT48Yj5GaW5kPC9iPjxtYWdpY3RhZz50aGU8L21hZ2ljdGFnPjxjPmxhZHkhPC9jPjxkPjwvZD48L2E+IikpCisKKyAgICAgICAgIyBNYWtlIHN1cmUgYWxsIHRoZSByZWxhdGlvbnNoaXBzIGFyZSBob29rZWQgdXAgY29ycmVjdGx5LgorICAgICAgICBiX3RhZyA9IHNvdXAuYgorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGJfdGFnLm5leHRfc2libGluZywgbWFnaWNfdGFnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKG1hZ2ljX3RhZy5wcmV2aW91c19zaWJsaW5nLCBiX3RhZykKKworICAgICAgICBmaW5kID0gYl90YWcuZmluZCh0ZXh0PSJGaW5kIikKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChmaW5kLm5leHRfZWxlbWVudCwgbWFnaWNfdGFnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKG1hZ2ljX3RhZy5wcmV2aW91c19lbGVtZW50LCBmaW5kKQorCisgICAgICAgIGNfdGFnID0gc291cC5jCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobWFnaWNfdGFnLm5leHRfc2libGluZywgY190YWcpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoY190YWcucHJldmlvdXNfc2libGluZywgbWFnaWNfdGFnKQorCisgICAgICAgIHRoZSA9IG1hZ2ljX3RhZy5maW5kKHRleHQ9InRoZSIpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwodGhlLnBhcmVudCwgbWFnaWNfdGFnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHRoZS5uZXh0X2VsZW1lbnQsIGNfdGFnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGNfdGFnLnByZXZpb3VzX2VsZW1lbnQsIHRoZSkKKworICAgIGRlZiB0ZXN0X2FwcGVuZF9jaGlsZF90aGF0c19hbHJlYWR5X2F0X3RoZV9lbmQoc2VsZik6CisgICAgICAgIGRhdGEgPSAiPGE+PGI+PC9iPjwvYT4iCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoZGF0YSkKKyAgICAgICAgc291cC5hLmFwcGVuZChzb3VwLmIpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoZGF0YSwgc291cC5kZWNvZGUoKSkKKworICAgIGRlZiB0ZXN0X21vdmVfdGFnX3RvX2JlZ2lubmluZ19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sKGV4dHJhY3RlZC5wcmV2aW91c19lbGVtZW50LCBOb25lKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGV4dHJhY3RlZC5uZXh0X2VsZW1lbnQubmV4dF9lbGVtZW50LCBOb25lKQorCisgICAgICAgICMgVGhlIGdhcCB3aGVyZSB0aGUgZXh0cmFjdGVkIHRhZyB1c2VkIHRvIGJlIGhhcyBiZWVuIG1lbmRlZC4KKyAgICAgICAgY29udGVudF8xID0gc291cC5maW5kKHRleHQ9IlNvbWUgY29udGVudC4gIikKKyAgICAgICAgY29udGVudF8yID0gc291cC5maW5kKHRleHQ9IiBNb3JlIGNvbnRlbnQuIikKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChjb250ZW50XzEubmV4dF9lbGVtZW50LCBjb250ZW50XzIpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoY29udGVudF8xLm5leHRfc2libGluZywgY29udGVudF8yKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGNvbnRlbnRfMi5wcmV2aW91c19lbGVtZW50LCBjb250ZW50XzEpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoY29udGVudF8yLnByZXZpb3VzX3NpYmxpbmcsIGNvbnRlbnRfMSkKKworICAgIGRlZiB0ZXN0X2V4dHJhY3RfZGlzdGluZ3Vpc2hlc19iZXR3ZWVuX2lkZW50aWNhbF9zdHJpbmdzKHNlbGYpOgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCI8YT5mb288L2E+PGI+YmFyPC9iPiIpCisgICAgICAgIGZvb18xID0gc291cC5hLnN0cmluZworICAgICAgICBiYXJfMSA9IHNvdXAuYi5zdHJpbmcKKyAgICAgICAgZm9vXzIgPSBzb3VwLm5ld19zdHJpbmcoImZvbyIpCisgICAgICAgIGJhcl8yID0gc291cC5uZXdfc3RyaW5nKCJiYXIiKQorICAgICAgICBzb3VwLmEuYXBwZW5kKGZvb18yKQorICAgICAgICBzb3VwLmIuYXBwZW5kKGJhcl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XRzIG51bWJlciBvZiBjaGlsZHJlbi4iIiIKKyAgICAgICAgc291cCA9IHNlbGYuc291cCgiPHRvcD4xPGI+MjwvYj4zPC90b3A+IikKKworICAgICAgICAjIFRoZSBCZWF1dGlmdWxTb3VwIG9iamVjdCBpdHNlbGYgY29udGFpbnMgb25lIGVsZW1lbnQ6IHRoZQorICAgICAgICAjIDx0b3A+IHRhZy4KKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChsZW4oc291cC5jb250ZW50cyksIDEpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobGVuKHNvdXApLCAxKQorCisgICAgICAgICMgVGhlIDx0b3A+IHRhZyBjb250YWlucyB0aHJlZSBlbGVtZW50czogdGhlIHRleHQgbm9kZSAiMSIsIHRoZQorICAgICAgICAjIDxiPiB0YWcsIGFuZCB0aGUgdGV4dCBub2RlICIzIi4KKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChsZW4oc291cC50b3ApLCAzKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGxlbihzb3VwLnRvcC5jb250ZW50cyksIDMpCisKKyAgICBkZWYgdGVzdF9tZW1iZXJfYWNjZXNzX2ludm9rZXNfZmluZChzZWxmKToKKyAgICAgICAgIiIiQWNjZXNzaW5nIGEgUHl0aG9uIG1lbWJlciAuZm9vIGludm9rZXMgZmluZCgnZm9vJykiIiIKKyAgICAgICAgc291cCA9IHNlbGYuc291cCgnPGI+PGk+PC9pPjwvYj4nKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNvdXAuYiwgc291cC5maW5kKCdiJykpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc291cC5iLmksIHNvdXAuZmluZCgnYicpLmZpbmQoJ2knKSkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChzb3VwLmEsIE5vbmUpCisKKyAgICBkZWYgdGVzdF9kZXByZWNhdGVkX21lbWJlcl9hY2Nlc3Moc2VsZik6CisgICAgICAgIHNvdXAgPSBzZ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nRhaW5pbmdfdW5pY29kZV9zdHJpbmdfY2FuX2JlX2VuY29kZWQoc2VsZik6CisgICAgICAgIGh0bWwgPSB1IjxiPlxOe1NOT1dNQU59PC9iPiIKKyAgICAgICAgc291cCA9IHNlbGYuc291cChodG1sKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKAorICAgICAgICAgICAgc291cC5iLmVuY29kZSgidXRmLTgiKSwgaHRtbC5lbmNvZGUoInV0Zi04IikpCisKKyAgICBkZWYgdGVzdF9lbmNvZGluZ19zdWJzdGl0dXRlc191bnJlY29nbml6ZWRfY2hhcmFjdGVyc19ieV9kZWZhdWx0KHNlbGYpOgorICAgICAgICBodG1sID0gdSI8Yj5cTntTTk9XTUFOfTwvYj4iCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoaHRtbCkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChzb3VwLmIuZW5jb2RlKCJhc2NpaSIpLCBiIjxiPiYjOTczMTs8L2I+IikKKworICAgIGRlZiB0ZXN0X2VuY29kaW5nX2Nhbl9iZV9tYWRlX3N0cmljdChzZWxmKToKKyAgICAgICAgaHRtbCA9IHUiPGI+XE57U05PV01BTn08L2I+IgorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKGh0bWwpCisgICAgICAgIHNlbGYuYXNzZXJ0UmFpc2VzKAorICAgICAgICAgICAgVW5pY29kZUVuY29kZUVycm9yLCBzb3VwLmVuY29kZSwgImFzY2lpIiwgZXJyb3JzPSJzdHJpY3QiKQorCisgICAgZGVmIHRlc3RfZGVjb2RlX2NvbnRlbnRzKHNlbGYpOgorICAgICAgICBodG1sID0gdSI8Yj5cTntTTk9XTUFOfTwvYj4iCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoaHRtbCkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCh1IlxOe1NOT1dNQU59Iiwgc291cC5iLmRlY29kZV9jb250ZW50cygpKQorCisgICAgZGVmIHRlc3RfZW5jb2RlX2NvbnRlbnRzKHNlbGYpOgorICAgICAgICBodG1sID0gdSI8Yj5cTntTTk9XTUFOfTwvYj4iCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoaHRtbCkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCgKKyAgICAgICAgICAgIHUiXE57U05PV01BTn0iLmVuY29kZSgidXRmOCIpLCBzb3VwLmIuZW5jb2RlX2NvbnRlbnRzKAorICAgICAgICAgICAgICAgIGVuY29kaW5nPSJ1dGY4IikpCisKKyAgICBkZWYgdGVzdF9kZXByZWNhdGVkX3JlbmRlckNvbnRlbnRzKHNlbGYpOgorICAgICAgICBodG1sID0gdSI8Yj5cTntTTk9XTUFOfTwvYj4iCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoaHRtbCkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCgKKyAgICAgICAgICAgIHUiXE57U05PV01BTn0iLmVuY29kZSgidXRmOCIpLCBzb3VwLmIucmVuZGVyQ29udGVudHMoKSkKKworY2xhc3MgVGVzdE5hdmlnYWJsZVN0cmluZ1N1YmNsYXNzZXMoU291cFRlc3QpOgorCisgICAgZGVmIHRlc3RfY2RhdGEoc2VsZik6CisgICAgICAgICMgTm9uZSBvZiB0aGUgY3VycmVudCBidWlsZGVycyB0dXJuIENEQVRBIHNlY3Rpb25zIGludG8gQ0RhdGEKKyAgICAgICAgIyBvYmplY3RzLCBidXQgeW91IGNhbiBjcmVhdGUgdGhlbSBtYW51YWxseS4KKyAgICAgICAgc291cCA9IHNlbGYuc291cCgiIikKKyAgICAgICAgY2RhdGEgPSBDRGF0YSgiZm9vIikKKyAgICAgICAgc291cC5pbnNlcnQoMSwgY2RhdGEpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwoc3RyKHNvdXApLCAiPCFbQ0RBVEFbZm9vXV0+IikKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChzb3VwLmZpbmQodGV4dD0iZm9vIiksICJmb28iKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNvdXAuY29udGVudHNbMF0sICJmb28iKQorCisgICAgZGVmIHRlc3RfY2RhdGFfaXNfbmV2ZXJfZm9ybWF0dGVkKHNlbGYpOgorICAgICAgICAiIiJUZXh0IGluc2lkZSBhIENEYXRhIG9iamVjdCBpcyBwYXNzZWQgaW50byB0aGUgZm9ybWF0dGVyLgorCisgICAgICAgIEJ1dCB0aGUgcmV0dXJuIHZhbHVlIGlzIGlnbm9yZWQuCisgICAgICAgICIiIgorCisgICAgICAgIHNlbGYuY291bnQgPSAwCisgICAgICAgIGRlZiBpbmNyZW1lbnQoKmFyZ3MpOgorICAgICAgICAgICAgc2VsZi5jb3VudCArPSAxCisgICAgICAgICAgICByZXR1cm4gIkJJVFRFUiBGQUlMVVJFIgorCisgICAgICAgIHNvdXAgPSBzZWxmLnNvdXAoIiIpCisgICAgICAgIGNkYXRhID0gQ0RhdGEoIjw+PD48PiIpCisgICAgICAgIHNvdXAuaW5zZXJ0KDEsIGNkYXRhKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKAorICAgICAgICAgICAgYiI8IVtDREFUQVs8Pjw+PD5dXT4iLCBzb3VwLmVuY29kZShmb3JtYXR0ZXI9aW5jcmVtZW50KSkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbCgxLCBzZWxmLmNvdW50KQorCisgICAgZGVmIHRlc3RfZG9jdHlwZV9lbmRzX2luX25ld2xpbmUoc2VsZik6CisgICAgICAgICMgVW5saWtlIG90aGVyIE5hdmlnYWJsZVN0cmluZyBzdWJjbGFzc2VzLCBhIERPQ1RZUEUgYWx3YXlzIGVuZHMKKyAgICAgICAgIyBpbiBhIG5ld2xpbmUuCisgICAgICAgIGRvY3R5cGUgPSBEb2N0eXBlKCJmb28iKQorICAgICAgICBzb3VwID0gc2VsZi5zb3VwKCIiKQorICAgICAgICBzb3VwLmluc2VydCgxLCBkb2N0eXBlKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKHNvdXAuZW5jb2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dHMKKworICAgIGRlZiBhc3NlcnRTZWxlY3RNdWx0aXBsZShzZWxmLCAqdGVzdHMpOgorICAgICAgICBmb3Igc2VsZWN0b3IsIGV4cGVjdGVkX2lkcyBpbiB0ZXN0czoKKyAgICAgICAgICAgIHNlbGYuYXNzZXJ0U2VsZWN0KHNlbGVjdG9yLCBleHBlY3RlZF9pZHMpCisKKyAgICBkZWYgdGVzdF9vbmVfdGFnX29uZShzZWxmKToKKyAgICAgICAgZWxzID0gc2VsZi5zb3VwLnNlbGVjdCgndGl0bGUnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGxlbihlbHMpLCAxKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGVsc1swXS5uYW1lLCAndGl0bGUnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGVsc1swXS5jb250ZW50cywgW3UnVGhlIHRpdGxlJ10pCisKKyAgICBkZWYgdGVzdF9vbmVfdGFnX21hbnkoc2VsZik6CisgICAgICAgIGVscyA9IHNlbGYuc291cC5zZWxlY3QoJ2RpdicpCisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobGVuKGVscyksIDMpCisgICAgICAgIGZvciBkaXYgaW4gZWxzOgorICAgICAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChkaXYubmFtZSwgJ2RpdicpCisKKyAgICBkZWYgdGVzdF90YWdfaW5fdGFnX29uZShzZWxmKToKKyAgICAgICAgZWxzID0gc2VsZi5zb3VwLnNlbGVjdCgnZGl2IGRpdicpCisgICAgICAgIHNlbGYuYXNzZXJ0U2VsZWN0cygnZGl2IGRpdicsIFsnaW5uZXInXSkKKworICAgIGRlZiB0ZXN0X3RhZ19pbl90YWdfbWFueShzZWxmKToKKyAgICAgICAgZm9yIHNlbGVjdG9yIGluICgnaHRtbCBkaXYnLCAnaHRtbCBib2R5IGRpdicsICdib2R5IGRpdicpOgorICAgICAgICAgICAgc2VsZi5hc3NlcnRTZWxlY3RzKHNlbGVjdG9yLCBbJ21haW4nLCAnaW5uZXInLCAnZm9vdGVyJ10pCisKKyAgICBkZWYgdGVzdF90YWdfbm9fbWF0Y2goc2VsZik6CisgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobGVuKHNlbGYuc291cC5zZWxlY3QoJ2RlbCcpKSwgMCkKKworICAgIGRlZiB0ZXN0X2ludmFsaWRfdGFnKHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydFJhaXNlcyhWYWx1ZUVycm9yLCBzZWxmLnNvdXAuc2VsZWN0LCAndGFnJXQnKQorCisgICAgZGVmIHRlc3RfaGVhZGVyX3RhZ3Moc2VsZik6CisgICAgICAgIHNlbGYuYXNzZXJ0U2VsZWN0TXVsdGlwbGUoCisgICAgICAgICAgICAoJ2gxJywgWydoZWFkZXIxJ10pLAorICAgICAgICAgICAgKCdoMicsIFsnaGVhZGVyMicsICdoZWFkZXIzJ10pLAorICAgICAgICApCisKKyAgICBkZWYgdGVzdF9jbGFzc19vbmUoc2VsZik6CisgICAgICAgIGZvciBzZWxlY3RvciBpbiAoJy5vbmVwJywgJ3Aub25lcCcsICdodG1sIHAub25lcCcpOgorICAgICAgICAgICAgZWxzID0gc2VsZi5zb3VwLnNlbGVjdChzZWxlY3RvcikKKyAgICAgICAgICAgIHNlbGYuYXNzZXJ0RXF1YWwobGVuKGVscyksIDEpCisgICAgICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGVsc1swXS5uYW1lLCAncCcpCisgICAgICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGVsc1swXVsnY2xhc3MnXSwgWydvbmVwJ10pCisKKyAgICBkZWYgdGVzdF9jbGFzc19taXNtYXRjaGVkX3RhZyhzZWxmKToKKyAgICAgICAgZWxzID0gc2VsZi5zb3VwLnNlbGVjdCgnZGl2Lm9uZXAnKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGxlbihlbHMpLCAwKQorCisgICAgZGVmIHRlc3Rfb25lX2lkKHNlbGYpOgorICAgICAgICBmb3Igc2VsZWN0b3Iga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bJ2wxJ10pLAorICAgICAgICAgICAgKCdsaW5rW3R5cGU9InRleHQvY3NzIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdsaW5rW2hyZWY9ImJsYWguY3NzIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdsaW5rW2hyZWY9Im5vLWJsYWguY3NzIl0nLCBbXSksCisgICAgICAgICAgICAoJ1tyZWw9InN0eWxlc2hlZXQiXScsIFsnbDEnXSksCisgICAgICAgICAgICAoJ1t0eXBlPSJ0ZXh0L2NzcyJdJywgWydsMSddKSwKKyAgICAgICAgICAgICgnW2hyZWY9ImJsYWguY3NzIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdbaHJlZj0ibm8tYmxhaC5jc3MiXScsIFtdKSwKKyAgICAgICAgICAgICgncFtocmVmPSJuby1ibGFoLmNzcyJdJywgW10pLAorICAgICAgICAgICAgKCdbaHJlZj0ibm8tYmxhaC5jc3MiXScsIFtdKSwKKyAgICAgICAgKQorCisgICAgZGVmIHRlc3RfYXR0cmlidXRlX3RpbGRlKHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydFNlbGVjdE11bHRpcGxlKAorICAgICAgICAgICAgKCdwW2NsYXNzfj0iY2xhc3MxIl0nLCBbJ3BtdWx0aSddKSwKKyAgICAgICAgICAgICgncFtjbGFzc349ImNsYXNzMiJdJywgWydwbXVsdGknXSksCisgICAgICAgICAgICAoJ3BbY2xhc3N+PSJjbGFzczMiXScsIFsncG11bHRpJ10pLAorICAgICAgICAgICAgKCdbY2xhc3N+PSJjbGFzczEiXScsIFsncG11bHRpJ10pLAorICAgICAgICAgICAgKCdbY2xhc3N+PSJjbGFzczIiXScsIFsncG11bHRpJ10pLAorICAgICAgICAgICAgKCdbY2xhc3N+PSJjbGFzczMiXScsIFsncG11bHRpJ10pLAorICAgICAgICAgICAgKCdhW3JlbH49ImZyaWVuZCJdJywgWydib2InXSksCisgICAgICAgICAgICAoJ2FbcmVsfj0ibWV0Il0nLCBbJ2JvYiddKSwKKyAgICAgICAgICAgICgnW3JlbH49ImZyaWVuZCJdJywgWydib2InXSksCisgICAgICAgICAgICAoJ1tyZWx+PSJtZXQiXScsIFsnYm9iJ10pLAorICAgICAgICApCisKKyAgICBkZWYgdGVzdF9hdHRyaWJ1dGVfc3RhcnRzd2l0aChzZWxmKToKKyAgICAgICAgc2VsZi5hc3NlcnRTZWxlY3RNdWx0aXBsZSgKKyAgICAgICAgICAgICgnW3JlbF49InN0eWxlIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdsaW5rW3JlbF49InN0eWxlIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdub3RsaW5rW3JlbF49Im5vdHN0eWxlIl0nLCBbXSksCisgICAgICAgICAgICAoJ1tyZWxePSJub3RzdHlsZSJdJywgW10pLAorICAgICAgICAgICAgKCdsaW5rW3JlbF49Im5vdHN0eWxlIl0nLCBbXSksCisgICAgICAgICAgICAoJ2xpbmtbaHJlZl49ImJsYSJdJywgWydsMSddKSwKKyAgICAgICAgICAgICgnYVtocmVmXj0iaHR0cDovLyJdJywgWydib2InLCAnbWUnXSksCisgICAgICAgICAgICAoJ1tocmVmXj0iaHR0cDovLyJdJywgWydib2InLCAnbWUnXSksCisgICAgICAgICAgICAoJ1tpZF49InAiXScsIFsncG11bHRpJywgJ3AxJ10pLAorICAgICAgICAgICAgKCdbaWRePSJtIl0nLCBbJ21lJywgJ21haW4nXSksCisgICAgICAgICAgICAoJ2RpdltpZF49Im0iXScsIFsnbWFpbiddKSwKKyAgICAgICAgICAgICgnYVtpZF49Im0iXScsIFsnbWUnXSksCisgICAgICAgICkKKworICAgIGRlZiB0ZXN0X2F0dHJpYnV0ZV9lbmRzd2l0aChzZWxmKToKKyAgICAgICAgc2VsZi5hc3NlcnRTZWxlY3RNdWx0aXBsZSgKKyAgICAgICAgICAgICgnW2hyZWYkPSIuY3NzIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdsaW5rW2hyZWYkPSIuY3NzIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdsaW5rW2lkJD0iMSJdJywgWydsMSddKSwKKyAgICAgICAgICAgICgnW2lkJD0iMSJdJywgWydsMScsICdwMScsICdoZWFkZXIxJywgJ3MxYTEnLCAnczJhMScsICdzMWEyczEnXSksCisgICAgICAgICAgICAoJ2RpdltpZCQ9IjEiXScsIFtdKSwKKyAgICAgICAgICAgICgnW2lkJD0ibm9lbmRpbmciXScsIFtdKSwKKyAgICAgICAgKQorCisgICAgZGVmIHRlc3RfYXR0cmlidXRlX2NvbnRhaW5zKHNlbGYpOgorICAgICAgICBzZWxmLmFzc2VydFNlbGVjdE11bHRpcGxlKAorICAgICAgICAgICAgIyBGcm9tIHRlc3RfYXR0cmlidXRlX3N0YXJ0c3dpdGgKKyAgICAgICAgICAgICgnW3JlbCo9InN0eWxlIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdsaW5rW3JlbCo9InN0eWxlIl0nLCBbJ2wxJ10pLAorICAgICAgICAgICAgKCdub3RsaW5rW3JlbCo9Im5vdHN0eWxlIl0nLCBbXSksCisgICAgICAgICAgICAoJ1tyZWwqPSJub3RzdHlsZSJdJywgW10pLAorICAgICAgICAgICAgKCdsaW5rW3JlbCo9Im5vdHN0eWxlIl0nLCBbXSksCisgICAgICAgICAgICAoJ2xpbmtbaHJlZio9ImJsYSJdJywgWydsMSddKSwKKyAgICAgICAgICAgICgnYVtocmVmKj0iaHR0cDovLyJdJywgWydib2InLCAnbWUnXSksCisgICAgICAgICAgICAoJ1tocmVmKj0iaHR0cDovLyJdJywgWydib2InLCAnbWUnXSksCisgICAgICAgICAgICAoJ1tpZCo9InAiXScsIFsncG11bHRpJywgJ3AxJ10pLAorICAgICAgICAgICAgKCdkaXZbaWQqPSJtIl0nLCBbJ21haW4nXSksCisgICAgICAgICAgICAoJ2FbaWQqPSJtIl0nLCBbJ21lJ10pLAorICAgICAgICAgICAgIyBGcm9tIHRlc3RfYXR0cmlidXRlX2VuZHN3aXRoCisgICAgICAgICAgICAoJ1tocmVmKj0iLmNzcyJdJywgWydsMSddKSwKKyAgICAgICAgICAgICgnbGlua1tocmVmKj0iLmNzcyJdJywgWydsMSddKSwKKyAgICAgICAgICAgICgnbGlua1tpZCo9IjEiXScsIFsnbDEnXSksCisgICAgICAgICAgICAoJ1tpZCo9IjEiXScsIFsnbDEnLCAncDEnLCAnaGVhZGVyMScsICdzMWExJywgJ3MxYTInLCAnczJhMScsICdzMWEyczEnXSksCisgICAgICAgICAgICAoJ2RpdltpZCo9IjEiXScsIFtdKSwKKyAgICAgICAgICAgICgnW2lkKj0ibm9lbmRpbmciXScsIFtdKSwKKyAgICAgICAgICAgICMgTmV3IGZvciB0aGlzIHRlc3QKKyAgICAgICAgICAgICgnW2hyZWYqPSIuIl0nLCBbJ2JvYicsICdtZScsICdsMSddKSwKKyAgICAgICAgICAgICgnYVtocmVmKj0iLiJdJywgWydib2InLCAnbWUnXSksCisgICAgICAgICAgICAoJ2xpbmtbaHJlZio9Ii4iXScsIFsnbDEnXSksCisgICAgICAgICAgICAoJ2RpdltpZCo9Im4iXScsIFsnbWFpbicsICdpbm5lciddKSwKKyAgICAgICAgICAgICgnZGl2W2lkKj0ibm4iXScsIFsnaW5uZXInXSksCisgICAgICAgICkKKworICAgIGRlZiB0ZXN0X2F0dHJpYnV0ZV9leGFjdF9vcl9oeXBlbihzZWxmKToKKyAgICAgICAgc2VsZi5hc3NlcnRTZWxlY3RNdWx0aXBsZSgKKyAgICAgICAgICAgICgncFtsYW5nfD0iZW4iXScsIFsnbGFuZy1lbicsICdsYW5nLWVuLWdiJywgJ2xhbmctZW4tdXMnXSksCisgICAgICAgICAgICAoJ1tsYW5nfD0iZW4iXScsIFsnbGFuZy1lbicsICdsYW5nLWVuLWdiJywgJ2xhbmctZW4tdXMnXSksCisgICAgICAgICAgICAoJ3BbbGFuZ3w9ImZyIl0nLCBbJ2xhbmctZnInXSksCisgICAgICAgICAgICAoJ3BbbGFuZ3w9ImdiIl0nLCBbXSksCisgICAgICAgICkKKworICAgIGRlZiB0ZXN0X2F0dHJpYnV0ZV9leGlzdHMoc2VsZik6CisgICAgICAgIHNlbGYuYXNzZXJ0U2VsZWN0TXVsdGlwbGUoCisgICAgICAgICAgICAoJ1tyZWxdJywgWydsMScsICdib2InLCAnbWUnXSksCisgICAgICAgICAgICAoJ2xpbmtbcmVsXScsIFsnbDEnXSksCisgICAgICAgICAgICAoJ2FbcmVsXScsIFsnYm9iJywgJ21lJ10pLAorICAgICAgICAgICAgKCdbbGFuZ10nLCBbJ2xhbmctZW4nLCAnbGFuZy1lbi1nYicsICdsYW5nLWVuLXVzJywgJ2xhbmctZnInXSksCisgICAgICAgICAgICAoJ3BbY2xhc3NdJywgWydwMScsICdwbXVsdGknXSksCisgICAgICAgICAgICAoJ1tibGFoXScsIFtdKSwKKyAgICAgICAgICAgICgncFtibGFoXScsIFtdKSwKKyAgICAgICAgKQorCisgICAgZGVmIHRlc3RfbnRoX29mX3R5cGUoc2VsZik6CisgICAgICAgICMgVHJ5IHRvIHNlbGVjdCBmaXJzdCBwYXJhZ3JhcGgKKyAgICAgICAgZWxzID0gc2VsZi5zb3VwLnNlbGVjdCgnZGl2I2lubmVyIHA6bnRoLW9mLXR5cGUoMSknKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGxlbihlbHMpLCAxKQorICAgICAgICBzZWxmLmFzc2VydEVxdWFsKGVsc1swXS5zdHJpbmcsIHUnU29tZSB0ZXh0JykKKworICAgICAgICAjIFRyeSB0byBzZWxlY3QgdGhpcmQgcGFyYWdyYXBoCisgICAgICAgIGVscyA9IHNlbGYuc291cC5zZWxlY3QoJ2RpdiNpbm5lciBwOm50aC1vZi10eXBlKDMpJykKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChsZW4oZWxzKSwgMSkKKyAgICAgICAgc2VsZi5hc3NlcnRFcXVhbChlbHNbMF0uc3RyaW5nLCB1J0Fub3RoZXInKQorCisgICAgICAgICMgVH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