Dataset Viewer
Auto-converted to Parquet Duplicate
repo_id
string
size
int64
file_path
string
content
string
shard_id
int64
DonnchaC/cia-hacking-tool-archive
30,220
dump/page_52920355.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/png" href="http://localhost:6081/IMG/favicon.ico"> <title>WMI Process Watcher</title> <link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="../../bootstrap/css/cerulean.min.css" rel="stylesheet"> <link href="../../bootstrap/css/new-gen.css" rel="stylesheet"> <link href="../../css/leak-styles.css" rel="stylesheet"> <link href="../../highlighter/efatmarker.css" rel="stylesheet"> <style> #efm-button {margin:0 0 4px 0;padding:0 0 0 30px;position:fixed;height:48px;width:52px;bottom:0;right:0;background:transparent '/highlighter/kedit-2.png' no-repeat bottom right;cursor:pointer;opacity:0.4;z-index:99999999999} #efm-button:hover {opacity:1} #efm-button #efm-menu {margin:0 0 52px 0;border:1px outset gray;padding:0;display:none;background:#eee;position:fixed;bottom:0;right:0;width:20em;opacity:1;cursor:auto} #efm-button:hover #efm-menu {display:block;font-size:smaller;color:#999} #efm-button #efm-menu p {margin:0;padding:0 3px} #efm-button #efm-menu a {margin:1px;padding:3px 3px;display:block;font:12px sans-serif;white-space:nowrap;opacity:inherit;cursor:pointer} #efm-button #efm-menu a:hover {color:black;background-color:white;opacity:1} #efm-button #efm-menu a > span {color:gray;position:absolute;right:4px} .efm-hi {background-color:#ff8;font-weight:normal;} </style> <link href="../../bootstrap/css/submit.css" rel="stylesheet"> <link href="main.css" rel="stylesheet"> </head> <body> <div id="submit_wlkey" class="submit_elem"> <div class="container"> <div class="text-center"><div class="submit_buttons btn-group" role="group"> <a href="page_52920355.html#submit_help_contact" class="btn-wl btn-wl-empty">How to contact WikiLeaks?</a> <a href="page_52920355.html#submit_help_tor" class="btn-wl btn-wl-empty">What is Tor?</a> <a href="page_52920355.html#submit_help_tips" class="btn-wl btn-wl-empty">Tips for Sources</a> <a href="page_52920355.html#submit_help_after" class="btn-wl btn-wl-empty">After Submitting</a> </div></div> <p>This key's fingerprint is A04C 5E09 ED02 B328 03EB 6116 93ED 732E 9231 8DBA</p> <pre> -----BEGIN PGP PUBLIC KEY BLOCK----- mQQNBFUoCGgBIADFLp+QonWyK8L6SPsNrnhwgfCxCk6OUHRIHReAsgAUXegpfg0b rsoHbeI5W9s5to/MUGwULHj59M6AvT+DS5rmrThgrND8Dt0dO+XW88bmTXHsFg9K jgf1wUpTLq73iWnSBo1m1Z14BmvkROG6M7+vQneCXBFOyFZxWdUSQ15vdzjr4yPR oMZjxCIFxe+QL+pNpkXd/St2b6UxiKB9HT9CXaezXrjbRgIzCeV6a5TFfcnhncpO ve59rGK3/az7cmjd6cOFo1Iw0J63TGBxDmDTZ0H3ecQvwDnzQSbgepiqbx4VoNmH OxpInVNv3AAluIJqN7RbPeWrkohh3EQ1j+lnYGMhBktX0gAyyYSrkAEKmaP6Kk4j /ZNkniw5iqMBY+v/yKW4LCmtLfe32kYs5OdreUpSv5zWvgL9sZ+4962YNKtnaBK3 1hztlJ+xwhqalOCeUYgc0Clbkw+sgqFVnmw5lP4/fQNGxqCO7Tdy6pswmBZlOkmH XXfti6hasVCjT1MhemI7KwOmz/KzZqRlzgg5ibCzftt2GBcV3a1+i357YB5/3wXE j0vkd+SzFioqdq5Ppr+//IK3WX0jzWS3N5Lxw31q8fqfWZyKJPFbAvHlJ5ez7wKA 1iS9krDfnysv0BUHf8elizydmsrPWN944Flw1tOFjW46j4uAxSbRBp284wiFmV8N TeQjBI8Ku8NtRDleriV3djATCg2SSNsDhNxSlOnPTM5U1bmh+Ehk8eHE3hgn9lRp 2kkpwafD9pXaqNWJMpD4Amk60L3N+yUrbFWERwncrk3DpGmdzge/tl/UBldPoOeK p3shjXMdpSIqlwlB47Xdml3Cd8HkUz8r05xqJ4DutzT00ouP49W4jqjWU9bTuM48 LRhrOpjvp5uPu0aIyt4BZgpce5QGLwXONTRX+bsTyEFEN3EO6XLeLFJb2jhddj7O DmluDPN9aj639E4vjGZ90Vpz4HpN7JULSzsnk+ZkEf2XnliRody3SwqyREjrEBui 9ktbd0hAeahKuwia0zHyo5+1BjXt3UHiM5fQN93GB0hkXaKUarZ99d7XciTzFtye /MWToGTYJq9bM/qWAGO1RmYgNr+gSF/fQBzHeSbRN5tbJKz6oG4NuGCRJGB2aeXW TIp/VdouS5I9jFLapzaQUvtdmpaeslIos7gY6TZxWO06Q7AaINgr+SBUvvrff/Nl l2PRPYYye35MDs0b+mI5IXpjUuBC+s59gI6YlPqOHXkKFNbI3VxuYB0VJJIrGqIu Fv2CXwy5HvR3eIOZ2jLAfsHmTEJhriPJ1sUG0qlfNOQGMIGw9jSiy/iQde1u3ZoF so7sXlmBLck9zRMEWRJoI/mgCDEpWqLX7hTTABEBAAG0x1dpa2lMZWFrcyBFZGl0 b3JpYWwgT2ZmaWNlIEhpZ2ggU2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBLZXkgKFlv dSBjYW4gY29udGFjdCBXaWtpTGVha3MgYXQgaHR0cDovL3dsY2hhdGMzcGp3cGxp NXIub25pb24gYW5kIGh0dHBzOi8vd2lraWxlYWtzLm9yZy90YWxrKSA8Y29udGFj dC11cy11c2luZy1vdXItY2hhdC1zeXN0ZW1Ad2lraWxlYWtzLm9yZz6JBD0EEwEK ACcCGwMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AFAlb6cdIFCQOznOoACgkQk+1z LpIxjbrlqh/7B2yBrryWhQMGFj+xr9TIj32vgUIMohq94XYqAjOnYdEGhb5u5B5p BNowcqdFB1SOEvX7MhxGAqYocMT7zz2AkG3kpf9f7gOAG7qA1sRiB+R7mZtUr9Kv fQSsRFPb6RNzqqB9I9wPNGhBh1YWusUPluLINwbjTMnHXeL96HgdLT+fIBa8ROmn 0fjJVoWYHG8QtsKiZ+lo2m/J4HyuJanAYPgL6isSu/1bBSwhEIehlQIfXZuS3j35 12SsO1Zj2BBdgUIrADdMAMLneTs7oc1/PwxWYQ4OTdkay2deg1g/N6YqM2N7rn1W 7A6tmuH7dfMlhcqw8bf5veyag3RpKHGcm7utDB6k/bMBDMnKazUnM2VQoi1mutHj kTCWn/vF1RVz3XbcPH94gbKxcuBi8cjXmSWNZxEBsbirj/CNmsM32Ikm+WIhBvi3 1mWvcArC3JSUon8RRXype4ESpwEQZd6zsrbhgH4UqF56pcFT2ubnqKu4wtgOECsw K0dHyNEiOM1lL919wWDXH9tuQXWTzGsUznktw0cJbBVY1dGxVtGZJDPqEGatvmiR o+UmLKWyxTScBm5o3zRm3iyU10d4gka0dxsSQMl1BRD3G6b+NvnBEsV/+KCjxqLU vhDNup1AsJ1OhyqPydj5uyiWZCxlXWQPk4p5WWrGZdBDduxiZ2FTj17hu8S4a5A4 lpTSoZ/nVjUUl7EfvhQCd5G0hneryhwqclVfAhg0xqUUi2nHWg19npPkwZM7Me/3 +ey7svRUqxVTKbXffSOkJTMLUWqZWc087hL98X5rfi1E6CpBO0zmHeJgZva+PEQ/ ZKKi8oTzHZ8NNlf1qOfGAPitaEn/HpKGBsDBtE2te8PF1v8LBCea/d5+Umh0GELh 5eTq4j3eJPQrTN1znyzpBYkR19/D/Jr5j4Vuow5wEE28JJX1TPi6VBMevx1oHBuG qsvHNuaDdZ4F6IJTm1ZYBVWQhLbcTginCtv1sadct4Hmx6hklAwQN6VVa7GLOvnY RYfPR2QA3fGJSUOg8xq9HqVDvmQtmP02p2XklGOyvvfQxCKhLqKi0hV9xYUyu5dk 2L/A8gzA0+GIN+IYPMsf3G7aDu0qgGpi5Cy9xYdJWWW0DA5JRJc4/FBSN7xBNsW4 eOMxl8PITUs9GhOcc68Pvwyv4vvTZObpUjZANLquk7t8joky4Tyog29KYSdhQhne oVODrdhTqTPn7rjvnwGyjLInV2g3pKw/Vsrd6xKogmE8XOeR8Oqk6nun+Y588Nsj XddctWndZ32dvkjrouUAC9z2t6VE36LSyYJUZcC2nTg6Uir+KUTs/9RHfrvFsdI7 iMucdGjHYlKc4+YwTdMivI1NPUKo/5lnCbkEDQRVKAhoASAAvnuOR+xLqgQ6KSOO RTkhMTYCiHbEsPmrTfNA9VIip+3OIzByNYtfFvOWY2zBh3H2pgf+2CCrWw3WqeaY wAp9zQb//rEmhwJwtkW/KXDQr1k95D5gzPeCK9R0yMPfjDI5nLeSvj00nFF+gjPo Y9Qb10jp/Llqy1z35Ub9ZXuA8ML9nidkE26KjG8FvWIzW8zTTYA5Ezc7U+8HqGZH VsK5KjIO2GOnJiMIly9MdhawS2IXhHTV54FhvZPKdyZUQTxkwH2/8QbBIBv0OnFY 3w75Pamy52nAzI7uOPOU12QIwVj4raLC+DIOhy7bYf9pEJfRtKoor0RyLnYZTT3N 0H4AT2YeTra17uxeTnI02lS2Jeg0mtY45jRCU7MrZsrpcbQ464I+F411+AxI3NG3 cFNJOJO2HUMTa+2PLWa3cERYM6ByP60362co7cpZoCHyhSvGppZyH0qeX+BU1oyn 5XhT+m7hA4zupWAdeKbOaLPdzMu2Jp1/QVao5GQ8kdSt0n5fqrRopO1WJ/S1eoz+ Ydy3dCEYK+2zKsZ3XeSC7MMpGrzanh4pk1DLr/NMsM5L5eeVsAIBlaJGs75Mp+kr ClQL/oxiD4XhmJ7MlZ9+5d/o8maV2K2pelDcfcW58tHm3rHwhmNDxh+0t5++i30y BIa3gYHtZrVZ3yFstp2Ao8FtXe/1ALvwE4BRalkh+ZavIFcqRpiF+YvNZ0JJF52V rwL1gsSGPsUY6vsVzhpEnoA+cJGzxlor5uQQmEoZmfxgoXKfRC69si0ReoFtfWYK 8Wu9sVQZW1dU6PgBB30X/b0Sw8hEzS0cpymyBXy8g+itdi0NicEeWHFKEsXa+HT7 mjQrMS7c84Hzx7ZOH6TpX2hkdl8Nc4vrjF4iff1+sUXj8xDqedrg29TseHCtnCVF kfRBvdH2CKAkbgi9Xiv4RqAP9vjOtdYnj7CIG9uccek/iu/bCt1y/MyoMU3tqmSJ c8QeA1L+HENQ/HsiErFGug+Q4Q1SuakHSHqBLS4TKuC+KO7tSwXwHFlFp47GicHe rnM4v4rdgKic0Z6lR3QpwoT9KwzOoyzyNlnM9wwnalCLwPcGKpjVPFg1t6F+eQUw WVewkizhF1sZBbED5O/+tgwPaD26KCNuofdVM+oIzVPOqQXWbaCXisNYXoktH3Tb 0X/DjsIeN4TVruxKGy5QXrvo969AQNx8Yb82BWvSYhJaXX4bhbK0pBIT9fq08d5R IiaN7/nFU3vavXa+ouesiD0cnXSFVIRiPETCKl45VM+f3rRHtNmfdWVodyXJ1O6T ZjQTB9ILcfcb6XkvH+liuUIppINu5P6i2CqzRLAvbHGunjvKLGLfvIlvMH1mDqxp VGvNPwARAQABiQQlBBgBCgAPAhsMBQJW+nHeBQkDs5z2AAoJEJPtcy6SMY26Qtgf /0tXRbwVOBzZ4fI5NKSW6k5A6cXzbB3JUxTHMDIZ93CbY8GvRqiYpzhaJVjNt2+9 zFHBHSfdbZBRKX8N9h1+ihxByvHncrTwiQ9zFi0FsrJYk9z/F+iwmqedyLyxhIEm SHtWiPg6AdUM5pLu8GR7tRHagz8eGiwVar8pZo82xhowIjpiQr0Bc2mIAusRs+9L jc+gjwjbhYIg2r2r9BUBGuERU1A0IB5Fx+IomRtcfVcL/JXSmXqXnO8+/aPwpBuk bw8sAivSbBlEu87P9OovsuEKxh/PJ65duQNjC+2YxlVcF03QFlFLGzZFN7Fcv5JW lYNeCOOz9NP9TTsR2EAZnacNk75/FYwJSJnSblCBre9xVA9pI5hxb4zu7CxRXuWc QJs8Qrvdo9k4Jilx5U9X0dsiNH2swsTM6T1gyVKKQhf5XVCS4bPWYagXcfD9/xZE eAhkFcAuJ9xz6XacT9j1pw50MEwZbwDneV93TqvHmgmSIFZow1aU5ACp+N/ksT6E 1wrWsaIJjsOHK5RZj/8/2HiBftjXscmL3K8k6MbDI8P9zvcMJSXbPpcYrffw9A6t ka9skmLKKFCcsNJ0coLLB+mw9DVQGc2dPWPhPgtYZLwG5tInS2bkdv67qJ4lYsRM jRCW5xzlUZYk6SWD4KKbBQoHbNO0Au8Pe/N1SpYYtpdhFht9fGmtEHNOGPXYgNLq VTLgRFk44Dr4hJj5I1+d0BLjVkf6U8b2bN5PcOnVH4Mb+xaGQjqqufAMD/IFO4Ro TjwKiw49pJYUiZbw9UGaV3wmg+fue9To1VKxGJuLIGhRXhw6ujGnk/CktIkidRd3 5pAoY5L4ISnZD8Z0mnGlWOgLmQ3IgNjAyUzVJRhDB5rVQeC6qX4r4E1xjYMJSxdz Aqrk25Y//eAkdkeiTWqbXDMkdQtig2rY+v8GGeV0v09NKiT+6extebxTaWH4hAgU FR6yq6FHs8mSEKC6Cw6lqKxOn6pwqVuXmR4wzpqCoaajQVz1hOgD+8QuuKVCcTb1 4IXXpeQBc3EHfXJx2BWbUpyCgBOMtvtjDhLtv5p+4XN55GqY+ocYgAhNMSK34AYD AhqQTpgHAX0nZ2SpxfLr/LDN24kXCmnFipqgtE6tstKNiKwAZdQBzJJlyYVpSk93 6HrYTZiBDJk4jDBh6jAx+IZCiv0rLXBM6QxQWBzbc2AxDDBqNbea2toBSww8HvHf hQV/G86Zis/rDOSqLT7e794ezD9RYPv55525zeCk3IKauaW5+WqbKlwosAPIMW2S kFODIRd5oMI51eof+ElmB5V5T9lw0CHdltSM/hmYmp/5YotSyHUmk91GDFgkOFUc J3x7gtxUMkTadELqwY6hrU8= =BLTH -----END PGP PUBLIC KEY BLOCK----- </pre> </div> </div> <div id="submit_help_contact" class="submit_elem"> <div class="container"> <div class="text-center"><div class="submit_buttons btn-group" role="group"> <a href="page_52920355.html#submit_help_contact" class="btn-wl">How to contact WikiLeaks?</a> <a href="page_52920355.html#submit_help_tor" class="btn-wl btn-wl-empty">What is Tor?</a> <a href="page_52920355.html#submit_help_tips" class="btn-wl btn-wl-empty">Tips for Sources</a> <a href="page_52920355.html#submit_help_after" class="btn-wl btn-wl-empty">After Submitting</a> </div></div> <h3>Contact</h3> <p>If you need help using Tor you can contact WikiLeaks for assistance in setting it up using our simple webchat available at: <a href="https://wikileaks.org/talk">https://wikileaks.org/talk</a></p> <p>If you can use Tor, but need to contact WikiLeaks for other reasons use our secured webchat available at <b>http://wlchatc3pjwpli5r.onion</b></p> <p>We recommend contacting us over Tor if you can.</p> </div> </div> <div id="submit_help_tor" class="submit_elem"> <div class="container"> <div class="text-center"><div class="submit_buttons btn-group" role="group"> <a href="page_52920355.html#submit_help_contact" class="btn-wl btn-wl-empty">How to contact WikiLeaks?</a> <a href="page_52920355.html#submit_help_tor" class="btn-wl">What is Tor?</a> <a href="page_52920355.html#submit_help_tips" class="btn-wl btn-wl-empty">Tips for Sources</a> <a href="page_52920355.html#submit_help_after" class="btn-wl btn-wl-empty">After Submitting</a> </div></div> <h3>Tor</h3> <p><a href="https://www.torproject.org">Tor</a> is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p> <p>In order to use the WikiLeaks public submission system as detailed above you can download the Tor Browser Bundle, which is a Firefox-like browser available for Windows, Mac OS X and GNU/Linux and pre-configured to connect using the anonymising system Tor.</p> <h4>Tails</h4> <p>If you are at high risk and you have the capacity to do so, you can also access the submission system through a secure operating system called <a href="https://tails.boum.org">Tails</a>. Tails is an operating system launched from a USB stick or a DVD that aim to leaves no traces when the computer is shut down after use and automatically routes your internet traffic through Tor. Tails will require you to have either a USB stick or a DVD at least 4GB big and a laptop or desktop computer.</p> </div> </div> <div id="submit_help_tips" class="submit_elem"> <div class="container"> <div class="text-center"> <div class="submit_buttons btn-group" role="group"> <a href="page_52920355.html#submit_help_contact" class="btn-wl btn-wl-empty">How to contact WikiLeaks?</a> <a href="page_52920355.html#submit_help_tor" class="btn-wl btn-wl-empty">What is Tor?</a> <a href="page_52920355.html#submit_help_tips" class="btn-wl">Tips for Sources</a> <a href="page_52920355.html#submit_help_after" class="btn-wl btn-wl-empty">After Submitting</a> </div> </div> <h3>Tips</h3> <p>Our submission system works hard to preserve your anonymity, but we recommend you also take some of your own precautions. Please review these basic guidelines. </p> <div> <h4>1. Contact us if you have specific problems</h4> <p>If you have a very large submission, or a submission with a complex format, or are a high-risk source, please <a href="page_52920355.html#submit_help_contact">contact us</a>. In our experience it is always possible to find a custom solution for even the most seemingly difficult situations.</p> </div> <div> <h4>2. What computer to use</h4> <p>If the computer you are uploading from could subsequently be audited in an investigation, consider using a computer that is not easily tied to you. Technical users can also use <a href="https://tails.boum.org">Tails</a> to help ensure you do not leave any records of your submission on the computer.</p> </div> <div> <h4>3. Do not talk about your submission to others</h4> <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p> </div> </div> </div> <div id="submit_help_after" class="submit_elem"> <div class="container"> <div class="text-center"> <div class="submit_buttons btn-group" role="group"> <a href="page_52920355.html#submit_help_contact" class="btn-wl btn-wl-empty">How to contact WikiLeaks?</a> <a href="page_52920355.html#submit_help_tor" class="btn-wl btn-wl-empty">What is Tor?</a> <a href="page_52920355.html#submit_help_tips" class="btn-wl btn-wl-empty">Tips for Sources</a> <a href="page_52920355.html#submit_help_after" class="btn-wl">After Submitting</a> </div> </div> <h3>After</h3> <div> <h4>1. Do not talk about your submission to others</h4> <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p> </div> <div> <h4>2. Act normal</h4> <p>If you are a high-risk source, avoid saying anything or doing anything after submitting which might promote suspicion. In particular, you should try to stick to your normal routine and behaviour.</p> </div> <div> <h4>3. Remove traces of your submission</h4> <p>If you are a high-risk source and the computer you prepared your submission on, or uploaded it from, could subsequently be audited in an investigation, we recommend that you format and dispose of the computer hard drive and any other storage media you used.</p> <p>In particular, hard drives retain data after formatting which may be visible to a digital forensics team and flash media (USB sticks, memory cards and SSD drives) retain data even after a secure erasure. If you used flash media to store sensitive data, it is important to destroy the media.</p> <p>If you do this and are a high-risk source you should make sure there are no traces of the clean-up, since such traces themselves may draw suspicion.</p> <div> <h4>4. If you face legal action</h4> <p>If a legal action is brought against you as a result of your submission, there are organisations that may help you. The Courage Foundation is an international organisation dedicated to the protection of journalistic sources. You can find more details at <a href="https://www.couragefound.org">https://www.couragefound.org</a>.</p> </div> </div> </div> </div> <div id="submit" class="submit_banner"> <div class="container"> <div class="page-header"> <h1>Submit documents to WikiLeaks</h1> <a class="remove-button" href="page_52920355.html#"><span class="glyphicon glyphicon-remove-circle"></span></a> </div> <p>WikiLeaks publishes documents of political or historical importance that are censored or otherwise suppressed. We specialise in strategic global publishing and large archives.</p> <p>The following is the address of our secure site where you can anonymously upload your documents to WikiLeaks editors. You can only access this submissions system through Tor. (See our <a href="page_52920355.html#submit_help_tor">Tor tab</a> for more information.) We also advise you to read our <a href="page_52920355.html#submit_help_tips">tips for sources</a> before submitting.</p> <div class="alert alert-info"> <div class="onion-url">wlupld3ptjvsgwqw.onion</div> <div> Copy this address into your Tor browser. Advanced users, if they wish, can also add a further layer of encryption to their submission using <a href="page_52920355.html#submit_wlkey">our public PGP key</a>. </div> </div> <p>If you cannot use Tor, or your submission is very large, or you have specific requirements, WikiLeaks provides several alternative methods. <a href="page_52920355.html#submit_help_contact">Contact us</a> to discuss how to proceed.</p> </div> </div> <div id="submit_help_buttons" class="submit_elem"> <div class="container"> <div class="text-center"> <div class="submit_buttons btn-group" role="group"> <a href="page_52920355.html#submit_help_contact" class="btn-wl btn-wl-empty">How to contact WikiLeaks?</a> <a href="page_52920355.html#submit_help_tor" class="btn-wl btn-wl-empty">What is Tor?</a> <a href="page_52920355.html#submit_help_tips" class="btn-wl btn-wl-empty">Tips for Sources</a> <a href="page_52920355.html#submit_help_after" class="btn-wl btn-wl-empty">After Submitting</a> </div> </div> </div> </div> <div id="main"> <link href="../../static/css/styles_topnav.css" rel="stylesheet"> <link href="../../static/css/styles_sidenav.css" rel="stylesheet"> <div class="top-navigation"> <nav class="navbar"> <a href="page_52920355.html#menu" class="mobile-only hot-dog nav-element"> </a> <div class="nav-logo"> <a href="https://wikileaks.org"> <h1>WikiLeaks</h1> </a> </div> <div class="action-buttons"> <a class="button-face support-link" href="https://wikileaks.spreadshirt.com/" target="_blank">Shop</a> <a class="button-face donate-link" href="https://shop.wikileaks.org/donate">Donate</a> <a class="button-face submit-link" href="page_52920355.html#submit">Submit</a> </div> <form class="global-search" method="get" action="https://search.wikileaks.org/"> <input type="text" name="q" placeholder="Search"> <button class="btn-search" type="submit"></button> </form> <div class="main-nav"> <ul class="first-level"> <li> <a class=" leaks-menu-item" href="https://wikileaks.org/-Leaks-.html">Leaks</a> </li> <li> <a class=" news-menu-item" href="https://wikileaks.org/-News-.html">News</a> </li> <li> <a class=" about-menu-item" href="https://wikileaks.org/-About-66-.html">About</a> </li> <li> <a class=" partners-menu-item" href="https://wikileaks.org/-Partners-.html">Partners</a> </li> </ul> </div> </nav> </div><nav id="menu" class="side-nav rub"> <div class="menu-wrapper"> <a class="close-btn nav-element" href="page_52920355.html#"></a> <ul class="first-level"> <li> <a class=" leaks-menu-item" href="https://wikileaks.org/-Leaks-.html">Leaks</a> </li> <li> <a class=" news-menu-item" href="https://wikileaks.org/-News-.html">News</a> </li> <li> <a class=" about-menu-item" href="https://wikileaks.org/-About-66-.html">About</a> </li> <li> <a class=" partners-menu-item" href="https://wikileaks.org/-Partners-.html">Partners</a> </li> </ul> <aside class="friends mobile-only"> <ul class="first-level"> <li> <a href="https://www.torproject.org/" target="_blank">Tor Project</a> </li> <li> <a href="https://tails.boum.org/" target="_blank">Tails</a> </li> <li> <a href="https://www.couragefound.org/" target="_blank">Courage</a> </li> <li> <a href="https://www.bitcoin.org/" target="_blank">Bitcoin</a> </li> </ul> </aside> <aside class="social mobile-only"> <ul> <li> <a href="https://www.facebook.com/wikileaks" class="nav-element" target="_blank" alt="Facebook"> <img class="img-responsive" src="../../static/img/fb-logo.png" alt="Facebook" title="Facebook page" /> </a> </li> <li> <a href="https://twitter.com/wikileaks" class="nav-element" target="_blank" alt="Twitter"> <img class="img-responsive" src="../../static/img/twitter-logo.png" alt="Twitter" title="Twitter page" /> </a> </li> </ul> </aside> </div> </nav> <div class="container-fluid row-fluid"> <div class="col-xs-12 col-sm-12 col-md-10 container-text"> <div class="leak-header"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body> <div class="title-area"> <h1 class="leak-title">Vault7: CIA Hacking Tools Revealed</h1> <img src="../logo.png"> </div> </body></html> <ul class="leak-navigation"> <a href="../index.html"><li>Releases</li></a> <a href="index.html"><li class="active">Documents</li></a> </ul> </div> <p>Navigation: » <a href="index.html">Directory</a> » <a href="space_3506177.html">AED Development Tradecraft</a> » <a href="page_3375113.html">AED Development Tradecraft Home</a> » <a href="page_16384750.html">Specific Tradecraft Techniques</a> » <a href="page_52920353.html">Process Enumeration</a></p> <hr> <div id="uniquer"> <p>Owner: <a class="user" href="user_2621804.html"><span class="user">User #71473</span></a></p> <h2>WMI Process Watcher</h2> <p>A technique to asynchronously detect when a process is created using WMI.</p> <p>The technique requires an EventSink object that contains a reference to a callback.  Registering the aynchronous detection is done by calling ExecNotificationQueryAsync() with the proper WQL async query and a pointer to the EventSink object.</p> <p>The queries need to detect creation and deletion of processes are as follows:</p> <ul> <li>SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'</li> <li>SELECT * FROM __InstanceDeletionEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'</li> </ul> <p> </p> <p>The callbacks must have the following signature:</p> <p style="margin-left: 30.0px;">void __cdecl CallBack(long lObjectCount, IWbemClassObject **apObjArray)</p> <p> </p> <p> </p> <hr> <h3>Previous versions:</h3> <p>| <a href="page_52920358.html">1</a> <span class="pg-tag"></span> |</p> </div> </div> </div> <script type="text/javascript" src="../../highlighter/mootools-core-and-more.js"></script> <script type="text/javascript" src="../../highlighter/efatmarker.min.js"></script> <div id="efm-button"> <div id="efm-menu"> <h3 style="margin:0 0 2px 0">e-Highlighter</h3> <a id="efm-permalink" class="efm-need-highlight" href="page_52920355.html" style="margin-bottom:0;padding-bottom:0;"></a> <p style="margin-top:0;padding-top:0" class="efm-need-highlight">Click to send permalink to address bar, or right-click to copy permalink.</p> <p style="margin:0.5em 0;padding:0;border-top:1px dotted #ccc;height:1px"></p> <a id="efm-unhighlightall" class="efm-need-highlight">Un-highlight all</a> <a id="efm-unhighlight">Un-highlight selection<span>u</span></a> <a id="efm-highlight">Highlight selection<span>h</span></a> </div> </div> <script type="text/javascript"> (function(){ window.addEvent('domready', function(){ var markerButton = $('efm-button'); if ( markerButton ) { eMarker = new EFatMarker($('uniquer')); eMarker.tokenToSpans(); // apply whatever token is there // need to act on mousedown or else selection disappear markerButton.addEvent('mousedown', function(){ eMarker.interpretSelection(true); return false; }); $('efm-unhighlightall').addEvent('mousedown', function(){ eMarker.unhighlightAll(true); return false; }); $('efm-unhighlight').addEvent('mousedown', function(){ eMarker.unhighlightSelection(true); return false; }); $('efm-highlight').addEvent('mousedown', function(){ eMarker.highlightSelection(true); return false; }); $('efm-permalink').addEvent('mousedown', function(){ window.location.href = this.href; return false; }); // if Mootools Keyboard is available, use it if (Keyboard) { var keyboard = new Keyboard({ defaultEventType: 'keyup', events: { 'h': function(){ eMarker.highlightSelection(true); }, 'u': function(){ eMarker.unhighlightSelection(true); } } }); keyboard.activate(); } eMarker.syncDOM(); // auto scroll to first highlight, if any if (eMarker.hasSpans()) { var scroll = new Fx.Scroll(window,{offset:{'x':0,'y':-100}}), highlights = $$('#uniquer .efm-hi'); if (highlights.length > 0) { scroll.toElement(highlights[0]); } } } }); })(); </script> <link href="../../static/css/styles_footer.css" rel="stylesheet"> <footer id="page-footer" class="footer-recommendations"> <div class="footer-wrapper"> <div class="recommendation-container"> <a href="page_52920355.html#" class="top">Top</a> <ul class="recommendation-links"> <li class="recommendation"> <a href="https://www.torproject.org/" target="_blank"> <div class="teaser"><img class="spip_logos" alt="" src="../../IMG/arton401.png?1461924517" width="300" height="180" /></div> <p> <p>Tor is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p> </p> </a> </li> <li class="recommendation"> <a href="https://tails.boum.org/" target="_blank"> <div class="teaser"><img class="spip_logos" alt="" src="../../IMG/arton405.png?1461924517" width="446" height="223" /></div> <p> <p>Tails is a live operating system, that you can start on almost any computer from a DVD, USB stick, or SD card. It aims at preserving your privacy and anonymity.</p> </p> </a> </li> <li class="recommendation"> <a href="https://www.couragefound.org/" target="_blank"> <div class="teaser"><img class="spip_logos" alt="" src="../../IMG/arton404.png?1461924517" width="357" height="50" /></div> <p> <p>The Courage Foundation is an international organisation that supports those who risk life or liberty to make significant contributions to the historical record.</p> </p> </a> </li> <li class="recommendation"> <a href="https://www.bitcoin.org/" target="_blank"> <div class="teaser"><img class="spip_logos" alt="" src="../../IMG/arton403.png?1461924517" width="300" height="64" /></div> <p> <p>Bitcoin uses peer-to-peer technology to operate with no central authority or banks; managing transactions and the issuing of bitcoins is carried out collectively by the network.</p> </p> </a> </li> </ul> <ul class="social-links"> <li> <a href="https://www.facebook.com/wikileaks" target="_blank" alt="Facebook"> <img src="../../static/img/fb-logo.png" alt="Facebook" title="Facebook page" /> </a> </li> <li> <a href="https://twitter.com/wikileaks" target="_blank" alt="Twitter"> <img src="../../static/img/twitter-logo.png" alt="Twitter" title="Twitter page" /> </a> </li> </ul> </div> </div> </footer> </div> <script src="../../bootstrap/js/jquery.min.js"></script> <script type="text/javascript"> var $j = jQuery.noConflict(); </script> <script src="../../bootstrap/js/bootstrap.min.js"></script> </body> </html>
0
jarmoza/twic
2,753
data/dickinson/input/tei/2781.tei
<?xml version="1.0" encoding="UTF-8"?> <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" ?> <TEI xmlns="http://www.tei-c.org/ns/1.0"> <teiHeader> <fileDesc> <titleStmt> <title>Of all the Sounds despatched abroad, </title> </titleStmt> <publicationStmt> <p>The Poems of Emily Dickinson, Johnson, 1955</p> </publicationStmt> <sourceDesc> <p>Emily Dickinson Archive</p> </sourceDesc> </fileDesc> </teiHeader> <text> <body> <div type="transcript" id="J321"> <lg type="stanza"> <l>Of all the Sounds despatched abroad,</l> <l>There's not a Charge to me</l> <l>Like that old measure in the Boughs --</l> <l>That phraseless Melody --</l> <l>The Wind does -- working like a Hand,</l> <l>Whose fingers Comb the Sky --</l> <l>Then quiver down -- with tufts of Tune --</l> <l>Permitted Gods, and me --</l> </lg> <lg type="stanza"> <l>Inheritance, it is, to us --</l> <l>Beyond the Art to Earn --</l> <l>Beyond the trait to take away</l> <l>By Robber, since the Gain</l> <l>Is gotten not of fingers --</l> <l>And inner than the Bone --</l> <l>Hid golden, for the whole of Days,</l> <l>And even in the Urn,</l> <l>I cannot vouch the merry Dust</l> <l>Do not arise and play</l> <l>In some odd fashion of it's own,</l> <l>Some quainter Holiday,</l> <l>When Winds go round and round in Bands --</l> <l>And thrum upon the door,</l> <l>And Birds take places, overhead,</l> <l>To bear them Orchestra.</l> </lg> <lg type="stanza"> <l>I crave Him grace of Summer Boughs,</l> <l>If such an Outcast be --</l> <l>Who never heard that fleshless Chant --</l> <l>Rise -- solemn -- on the Tree,</l> <l>As if some Caravan of Sound</l> <l>Off Deserts, in the Sky,</l> <l>Had parted Rank,</l> <l>Then knit, and swept --</l> <l>In Seamless Company --</l> </lg> </div> </body> </text> </TEI>
0
neocities/neocities
3,131
public/js/ace/theme-clouds.js
ace.define("ace/theme/clouds-css",["require","exports","module"],function(e,t,n){n.exports='.ace-clouds .ace_gutter {\n background: #ebebeb;\n color: #333\n}\n\n.ace-clouds .ace_print-margin {\n width: 1px;\n background: #e8e8e8\n}\n\n.ace-clouds {\n background-color: #FFFFFF;\n color: #000000\n}\n\n.ace-clouds .ace_cursor {\n color: #000000\n}\n\n.ace-clouds .ace_marker-layer .ace_selection {\n background: #BDD5FC\n}\n\n.ace-clouds.ace_multiselect .ace_selection.ace_start {\n box-shadow: 0 0 3px 0px #FFFFFF;\n}\n\n.ace-clouds .ace_marker-layer .ace_step {\n background: rgb(255, 255, 0)\n}\n\n.ace-clouds .ace_marker-layer .ace_bracket {\n margin: -1px 0 0 -1px;\n border: 1px solid #BFBFBF\n}\n\n.ace-clouds .ace_marker-layer .ace_active-line {\n background: #FFFBD1\n}\n\n.ace-clouds .ace_gutter-active-line {\n background-color : #dcdcdc\n}\n\n.ace-clouds .ace_marker-layer .ace_selected-word {\n border: 1px solid #BDD5FC\n}\n\n.ace-clouds .ace_invisible {\n color: #BFBFBF\n}\n\n.ace-clouds .ace_keyword,\n.ace-clouds .ace_meta,\n.ace-clouds .ace_support.ace_constant.ace_property-value {\n color: #AF956F\n}\n\n.ace-clouds .ace_keyword.ace_operator {\n color: #484848\n}\n\n.ace-clouds .ace_keyword.ace_other.ace_unit {\n color: #96DC5F\n}\n\n.ace-clouds .ace_constant.ace_language {\n color: #39946A\n}\n\n.ace-clouds .ace_constant.ace_numeric {\n color: #46A609\n}\n\n.ace-clouds .ace_constant.ace_character.ace_entity {\n color: #BF78CC\n}\n\n.ace-clouds .ace_invalid {\n background-color: #FF002A\n}\n\n.ace-clouds .ace_fold {\n background-color: #AF956F;\n border-color: #000000\n}\n\n.ace-clouds .ace_storage,\n.ace-clouds .ace_support.ace_class,\n.ace-clouds .ace_support.ace_function,\n.ace-clouds .ace_support.ace_other,\n.ace-clouds .ace_support.ace_type {\n color: #C52727\n}\n\n.ace-clouds .ace_string {\n color: #5D90CD\n}\n\n.ace-clouds .ace_comment {\n color: #BCC8BA\n}\n\n.ace-clouds .ace_entity.ace_name.ace_tag,\n.ace-clouds .ace_entity.ace_other.ace_attribute-name {\n color: #606060\n}\n\n.ace-clouds .ace_indent-guide {\n background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y\n}\n\n.ace-clouds .ace_indent-guide-active {\n background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAZSURBVHjaYvj///9/hivKyv8BAAAA//8DACLqBhbvk+/eAAAAAElFTkSuQmCC") right repeat-y;\n} \n'}),ace.define("ace/theme/clouds",["require","exports","module","ace/theme/clouds-css","ace/lib/dom"],function(e,t,n){t.isDark=!1,t.cssClass="ace-clouds",t.cssText=e("./clouds-css");var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass,!1)}); (function() { ace.require(["ace/theme/clouds"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; } }); })();
0
ComodoSecurity/openedr
3,211
edrav2/eprj/openssl/openssl/test/recipes/15-test_mp_rsa.t
#! /usr/bin/env perl # Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. # Copyright 2017 BaishanCloud. All rights reserved. # # Licensed under the OpenSSL license (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy # in the file LICENSE in the source distribution or at # https://www.openssl.org/source/license.html use strict; use warnings; use File::Spec; use OpenSSL::Test qw/:DEFAULT data_file/; use OpenSSL::Test::Utils; setup("test_mp_rsa"); plan tests => 31; ok(run(test(["rsa_mp_test"])), "running rsa multi prime test"); my $cleartext = data_file("plain_text"); my @test_param = ( # 3 primes, 2048-bit { primes => '3', bits => '2048', }, # 4 primes, 4096-bit { primes => '4', bits => '4096', }, # 5 primes, 8192-bit { primes => '5', bits => '8192', }, ); # genrsa run_mp_tests(0); # evp run_mp_tests(1); sub run_mp_tests { my $evp = shift; foreach my $param (@test_param) { my $primes = $param->{primes}; my $bits = $param->{bits}; my $name = ($evp ? "evp" : "") . "${bits}p${primes}"; if ($evp) { ok(run(app([ 'openssl', 'genpkey', '-out', 'rsamptest.pem', '-algorithm', 'RSA', '-pkeyopt', "rsa_keygen_primes:$primes", '-pkeyopt', "rsa_keygen_bits:$bits"])), "genrsa $name"); } else { ok(run(app([ 'openssl', 'genrsa', '-out', 'rsamptest.pem', '-primes', $primes, $bits])), "genrsa $name"); } ok(run(app([ 'openssl', 'rsa', '-check', '-in', 'rsamptest.pem', '-noout'])), "rsa -check $name"); if ($evp) { ok(run(app([ 'openssl', 'pkeyutl', '-inkey', 'rsamptest.pem', '-encrypt', '-in', $cleartext, '-out', 'rsamptest.enc' ])), "rsa $name encrypt"); ok(run(app([ 'openssl', 'pkeyutl', '-inkey', 'rsamptest.pem', '-decrypt', '-in', 'rsamptest.enc', '-out', 'rsamptest.dec' ])), "rsa $name decrypt"); } else { ok(run(app([ 'openssl', 'rsautl', '-inkey', 'rsamptest.pem', '-encrypt', '-in', $cleartext, '-out', 'rsamptest.enc' ])), "rsa $name encrypt"); ok(run(app([ 'openssl', 'rsautl', '-inkey', 'rsamptest.pem', '-decrypt', '-in', 'rsamptest.enc', '-out', 'rsamptest.dec' ])), "rsa $name decrypt"); } ok(check_msg(), "rsa $name check result"); # clean up temp files unlink 'rsamptest.pem'; unlink 'rsamptest.enc'; unlink 'rsamptest.dec'; } } sub check_msg { my $msg; my $dec; open(my $fh, "<", $cleartext) or return 0; binmode $fh; read($fh, $msg, 10240); close $fh; open($fh, "<", "rsamptest.dec") or return 0; binmode $fh; read($fh, $dec, 10240); close $fh; if ($msg ne $dec) { print STDERR "cleartext and decrypted are not the same"; return 0; } return 1; }
0
rotki/rotki
1,409
frontend/app/src/modules/accounts/balances/use-account-balances-refresh.ts
import type { MaybeRef } from '@vueuse/core'; import type { Ref } from 'vue'; import { useAccountCategoryHelper } from '@/composables/accounts/use-account-category-helper'; import { useRefresh } from '@/composables/balances/refresh'; import { useBlockchains } from '@/composables/blockchain'; interface AccountBalancesRefreshOptions { category: MaybeRef<string>; fetchData: () => Promise<void>; detailsTable: Ref<{ refresh: () => Promise<void> } | undefined>; } interface AccountBalancesRefreshReturn { refresh: () => Promise<void>; refreshClick: () => Promise<void>; } export function useAccountBalancesRefresh(options: AccountBalancesRefreshOptions): AccountBalancesRefreshReturn { const { category, detailsTable, fetchData } = options; const { handleBlockchainRefresh, refreshBlockchainBalances } = useRefresh(); const { fetchAccounts } = useBlockchains(); const { chainIds, isEvm } = useAccountCategoryHelper(category); const refreshClick = async (): Promise<void> => { await fetchAccounts(get(chainIds), true); if (get(isEvm)) await handleBlockchainRefresh(); else await refreshBlockchainBalances(get(chainIds)); await fetchData(); }; const refresh = async (): Promise<void> => { await fetchData(); if (!isDefined(detailsTable)) return; await get(detailsTable).refresh(); }; return { refresh, refreshClick, }; }
0
PSU-Security-Universe/countdown
4,493
countdown_fuzzer/pkg/report/testdata/linux/report/568
TITLE: KASAN: invalid-access Read in io_submit_sqes ALT: bad-access in io_submit_sqes [ 1344.478322][ T6700] ================================================================== [ 1344.479538][ T6700] BUG: KASAN: invalid-access in __memset+0x16c/0x188 [ 1344.480722][ T6700] Read at addr 0bff00002a0f4600 by task syz-executor.0/6700 [ 1344.481938][ T6700] Pointer tag: [0b], memory tag: [fe] [ 1344.483006][ T6700] [ 1344.484199][ T6700] CPU: 0 PID: 6700 Comm: syz-executor.0 Not tainted 5.11.0-rc3 #36 [ 1344.485714][ T6700] Hardware name: linux,dummy-virt (DT) [ 1344.486832][ T6700] Call trace: [ 1344.487421][ T6700] dump_backtrace+0x0/0x1a4 [ 1344.488255][ T6700] show_stack+0x1c/0x70 [ 1344.489062][ T6700] dump_stack+0xd0/0x12c [ 1344.489906][ T6700] print_address_description+0x70/0x29c [ 1344.490874][ T6700] kasan_report+0x104/0x200 [ 1344.491847][ T6700] __do_kernel_fault+0x17c/0x1c0 [ 1344.492697][ T6700] do_tag_check_fault+0x6c/0x80 [ 1344.493568][ T6700] do_mem_abort+0x44/0xb4 [ 1344.494435][ T6700] el1_abort+0x40/0x6c [ 1344.495260][ T6700] el1_sync_handler+0xb0/0xcc [ 1344.496197][ T6700] el1_sync+0x70/0x100 [ 1344.496937][ T6700] __memset+0x16c/0x188 [ 1344.497746][ T6700] io_submit_sqes+0x420/0x82c [ 1344.498574][ T6700] __arm64_sys_io_uring_enter+0x180/0x73c [ 1344.499530][ T6700] el0_svc_common.constprop.0+0x74/0x190 [ 1344.500534][ T6700] do_el0_svc+0x78/0x90 [ 1344.501438][ T6700] el0_svc+0x14/0x20 [ 1344.502237][ T6700] el0_sync_handler+0x1a8/0x1b0 [ 1344.503145][ T6700] el0_sync+0x190/0x1c0 [ 1344.504188][ T6700] [ 1344.504848][ T6700] Allocated by task 6367: [ 1344.505717][ T6700] stack_trace_save+0x50/0x80 [ 1344.506613][ T6700] kasan_save_stack+0x2c/0x60 [ 1344.507397][ T6700] ____kasan_kmalloc+0xe8/0x160 [ 1344.508272][ T6700] __kasan_slab_alloc+0x20/0x30 [ 1344.509134][ T6700] kmem_cache_alloc+0x1a8/0x304 [ 1344.510030][ T6700] io_uring_setup+0x24c/0xe10 [ 1344.510841][ T6700] __arm64_sys_io_uring_setup+0x20/0x30 [ 1344.511860][ T6700] el0_svc_common.constprop.0+0x74/0x190 [ 1344.512805][ T6700] do_el0_svc+0x78/0x90 [ 1344.513634][ T6700] el0_svc+0x14/0x20 [ 1344.514456][ T6700] el0_sync_handler+0x1a8/0x1b0 [ 1344.515343][ T6700] el0_sync+0x190/0x1c0 [ 1344.516214][ T6700] [ 1344.516845][ T6700] Freed by task 6119: [ 1344.517632][ T6700] stack_trace_save+0x50/0x80 [ 1344.518543][ T6700] kasan_save_stack+0x2c/0x60 [ 1344.519347][ T6700] kasan_set_track+0x2c/0x40 [ 1344.520127][ T6700] kasan_set_free_info+0x24/0x30 [ 1344.521091][ T6700] ____kasan_slab_free.constprop.0+0x184/0x1c0 [ 1344.522146][ T6700] __kasan_slab_free+0x14/0x20 [ 1344.523038][ T6700] slab_free_freelist_hook+0x9c/0x190 [ 1344.523977][ T6700] kmem_cache_free+0xa0/0x460 [ 1344.524799][ T6700] io_ring_exit_work+0x190/0x224 [ 1344.525696][ T6700] process_one_work+0x1d8/0x360 [ 1344.526516][ T6700] worker_thread+0x74/0x440 [ 1344.527320][ T6700] kthread+0x178/0x180 [ 1344.528089][ T6700] ret_from_fork+0x10/0x30 [ 1344.528922][ T6700] [ 1344.529488][ T6700] The buggy address belongs to the object at ffff00002a0f4600 [ 1344.529488][ T6700] which belongs to the cache io_kiocb of size 208 [ 1344.531168][ T6700] The buggy address is located 0 bytes inside of [ 1344.531168][ T6700] 208-byte region [ffff00002a0f4600, ffff00002a0f46d0) [ 1344.532920][ T6700] The buggy address belongs to the page: [ 1344.534051][ T6700] page:00000000289c8f05 refcount:1 mapcount:0 mapping:0000000000000000 index:0xf7ff00002a0f4400 pfn:0x6a0f4 [ 1344.535717][ T6700] flags: 0x1ffffc000000200(slab) [ 1344.537027][ T6700] raw: 01ffffc000000200 dead000000000100 dead000000000122 faff000004d2ab00 [ 1344.538299][ T6700] raw: f7ff00002a0f4400 000000008010000c 00000001ffffffff 0000000000000000 [ 1344.539527][ T6700] page dumped because: kasan: bad access detected [ 1344.540477][ T6700] [ 1344.541066][ T6700] Memory state around the buggy address: [ 1344.542279][ T6700] ffff00002a0f4400: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 1344.543535][ T6700] ffff00002a0f4500: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 1344.544798][ T6700] >ffff00002a0f4600: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 1344.545944][ T6700] ^ [ 1344.546740][ T6700] ffff00002a0f4700: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 1344.547936][ T6700] ffff00002a0f4800: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe [ 1344.549089][ T6700] ==================================================================
0
mdn/archived-content
11,127
files/ja/web/api/navigator/mozsocial/index.html
--- title: navigator.mozSocial slug: Web/API/Navigator/mozSocial tags: - DOM - Gecko DOM Reference - Social translation_of: Archive/mozSocial --- <div> <section class="Quick_links" id="Quick_Links"><ol><li><strong><a href="/ja/docs/Web/API/Navigator"><code>Navigator</code></a></strong></li><li class="toggle"><details open><summary>プロパティ</summary><ol><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/activeVRDisplays"><code>activeVRDisplays</code></a></li><li><span class="sidebar-icon"><span title="これは非推奨 API です。未だ動作しているかも知れませんが、将来的に削除される可能性があります。"><i class="icon-thumbs-down-alt"> </i></span></span><a href="/ja/docs/Web/API/NavigatorID/appCodeName"><code>appCodeName</code></a></li><li><span class="sidebar-icon"><span title="これは非推奨 API です。未だ動作しているかも知れませんが、将来的に削除される可能性があります。"><i class="icon-thumbs-down-alt"> </i></span></span><a href="/ja/docs/Web/API/NavigatorID/appName"><code>appName</code></a></li><li><span class="sidebar-icon"><span title="これは非推奨 API です。未だ動作しているかも知れませんが、将来的に削除される可能性があります。"><i class="icon-thumbs-down-alt"> </i></span></span><a href="/ja/docs/Web/API/NavigatorID/appVersion"><code>appVersion</code></a></li><li><span class="sidebar-icon"><span class="icon-only-inline" title="この API は標準化されていません。"><i class="icon-warning-sign"> </i></span></span><span class="sidebar-icon"><span class="icon-only-inline" title="これは廃止されたAPIであり、今後の動作は保障されていません。ご注意下さい。"><i class="icon-trash"> </i></span></span><s class="obsoleteElement"><a href="/ja/docs/Web/API/Navigator/battery"><code>battery</code></a></s></li><li><a href="/ja/docs/Web/API/Navigator/buildID"><code>buildID</code></a></li><li><a href="/ja/docs/Web/API/Navigator/clipboard"><code>clipboard</code></a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/connection"><code>connection</code></a></li><li><a href="/ja/docs/Web/API/Navigator/cookieEnabled"><code>cookieEnabled</code></a></li><li><a href="/ja/docs/Web/API/Navigator/credentials"><code>credentials</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/credentials$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/Navigator/deviceMemory"><code>deviceMemory</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/deviceMemory$translate">[翻訳する]</a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/doNotTrack"><code>doNotTrack</code></a></li><li><a href="/ja/docs/Web/API/Navigator/geolocation"><code>geolocation</code></a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/keyboard"><code>keyboard</code></a></li><li><a href="/ja/docs/Web/API/NavigatorLanguage/language"><code>language</code></a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/NavigatorLanguage/languages"><code>languages</code></a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/locks"><code>locks</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/locks$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/Navigator/maxTouchPoints"><code>maxTouchPoints</code></a></li><li><a href="/ja/docs/Web/API/Navigator/mediaDevices"><code>mediaDevices</code></a></li><li><a href="/ja/docs/Web/API/Navigator/mozBluetooth"><code>mozBluetooth</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/mozBluetooth$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/Navigator/mozTime"><code>mozTime</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/mozTime$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/NavigatorOnLine/onLine"><code>onLine</code></a></li><li><a href="/ja/docs/Web/API/Navigator/oscpu"><code>oscpu</code></a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/permissions"><code>permissions</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/permissions$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/NavigatorID/platform"><code>platform</code></a></li><li><span class="sidebar-icon"><span title="これは非推奨 API です。未だ動作しているかも知れませんが、将来的に削除される可能性があります。"><i class="icon-thumbs-down-alt"> </i></span></span><a href="/ja/docs/Web/API/NavigatorID/product"><code>product</code></a></li><li><a href="/ja/docs/Web/API/Navigator/productSub"><code>productSub</code></a></li><li><a href="/ja/docs/Web/API/Navigator/serviceWorker"><code>serviceWorker</code></a></li><li><span class="sidebar-icon"><span title="これは非推奨 API です。未だ動作しているかも知れませんが、将来的に削除される可能性があります。"><i class="icon-thumbs-down-alt"> </i></span></span><a href="/ja/docs/Web/API/NavigatorID/userAgent"><code>userAgent</code></a></li><li><a href="/ja/docs/Web/API/Navigator/vendor"><code>vendor</code></a></li><li><a href="/ja/docs/Web/API/Navigator/vendorSub"><code>vendorSub</code></a></li><li><a href="/ja/docs/Web/API/Navigator/webdriver"><code>webdriver</code></a></li></ol></details></li><li class="toggle"><details open><summary>メソッド</summary><ol><li><a href="/ja/docs/Web/API/Navigator/addIdleObserver"><code>addIdleObserver()</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/addIdleObserver$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/Navigator/getBattery"><code>getBattery()</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/getBattery$translate">[翻訳する]</a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/getGamepads"><code>getGamepads()</code></a></li><li><span class="sidebar-icon"><span title="これは非推奨 API です。未だ動作しているかも知れませんが、将来的に削除される可能性があります。"><i class="icon-thumbs-down-alt"> </i></span></span><a href="/ja/docs/Web/API/Navigator/getUserMedia"><code>getUserMedia</code></a></li><li><span class="sidebar-icon"><span title="これは実験段階の API です。製品内のコードで使用しないようご注意ください。"><i class="icon-beaker"> </i></span></span><a href="/ja/docs/Web/API/Navigator/getVRDisplays"><code>getVRDisplays()</code></a></li><li><span class="sidebar-icon"><span class="icon-only-inline" title="この API は標準化されていません。"><i class="icon-warning-sign"> </i></span></span><span class="sidebar-icon"><span class="icon-only-inline" title="これは廃止されたAPIであり、今後の動作は保障されていません。ご注意下さい。"><i class="icon-trash"> </i></span></span><s class="obsoleteElement"><a href="/ja/docs/Web/API/Navigator/mozIsLocallyAvailable"><code>mozIsLocallyAvailable()</code></a></s></li><li><span class="sidebar-icon"><span class="icon-only-inline" title="この API は標準化されていません。"><i class="icon-warning-sign"> </i></span></span><a href="/ja/docs/Web/API/Navigator/msLaunchUri"><code>msLaunchUri()</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/msLaunchUri$translate">[翻訳する]</a></li><li><span class="sidebar-icon"><span class="icon-only-inline" title="これは廃止されたAPIであり、今後の動作は保障されていません。ご注意下さい。"><i class="icon-trash"> </i></span></span><s class="obsoleteElement"><a href="/ja/docs/Web/API/Navigator/registerContentHandler"><code>registerContentHandler()</code></a></s></li><li><a href="/ja/docs/Web/API/Navigator/registerProtocolHandler"><code>registerProtocolHandler</code></a></li><li><a href="/ja/docs/Web/API/Navigator/requestMediaKeySystemAccess"><code>requestMediaKeySystemAccess()</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/requestMediaKeySystemAccess$translate">[翻訳する]</a></li><li><span class="sidebar-icon"><span class="icon-only-inline" title="この API は標準化されていません。"><i class="icon-warning-sign"> </i></span></span><a href="/ja/docs/Web/API/Navigator/requestWakeLock"><code>requestWakeLock()</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/requestWakeLock$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/Navigator/sendBeacon"><code>sendBeacon()</code></a></li><li><span class="sidebar-icon"><span title="これは非推奨 API です。未だ動作しているかも知れませんが、将来的に削除される可能性があります。"><i class="icon-thumbs-down-alt"> </i></span></span><a href="/ja/docs/Web/API/NavigatorID/taintEnabled"><code>taintEnabled()</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/NavigatorID/taintEnabled$translate">[翻訳する]</a></li><li><a href="/ja/docs/Web/API/Navigator/vibrate"><code>vibrate()</code></a> <a style="opacity: 0.5;" href="/ja/docs/Web/API/Navigator/vibrate$translate">[翻訳する]</a></li></ol></details></li></ol></section><div class="nonStandard nonStandardHeader notecard"> <p><strong><span class="icon-only-inline" title="この API は標準化されていません。"><i class="icon-warning-sign"> </i></span> 非標準</strong><br> この機能は標準ではなく、標準化の予定もありません。公開されているウェブサイトには使用しないでください。ユーザーによっては使用できないことがあります。実装ごとに大きな差があることもあり、将来は振る舞いが変わるかもしれません。</p> </div></div> <p><code>navigator.mozSocial</code> プロパティによって返される <code>MozSocial</code> オブジェクトは、ソーシャルメディアプロバイダーパネル内で利用することができます。ソーシャルメディアプロバイダーパネルが必要とする機能を提供します。</p> <div class="note notecard"> <p><strong>注記:</strong> Mozilla は最終的に標準化のためにこの API の提出を予定していますが、まだ実行には至っていません。</p> </div> <h2 id="Attributes" name="Attributes">属性</h2> <dl> <dt> <a href="/ja/docs/Web/API/MozSocial/isVisible" title="ソーシャルメディアプロバイダのコンテンツサイドバーが現在表示されているかどうかを示します。"><code>MozSocial.isVisible</code></a></dt> <dd> 真偽値を返す。コンテンツが表示されている場合は <code>true</code> を、表示されていない場合は <code>false</code> を返す。</dd> </dl> <h2 id="Methods" name="Methods">メソッド</h2> <dl> <dt> <a href="/ja/docs/Web/API/MozSocial/closePanel" title="親のソーシャルメディアプロバイダーパネルの内、現在開いているソーシャルパネルを閉じます。"><code>MozSocial.closePanel()</code></a></dt> <dd> 現在開いているフライアウトパネルを閉じます。</dd> <dt> <a href="/ja/docs/Web/API/MozSocial/getAttention" title="この項目についての文書はまだ書かれていません。書いてみませんか?"><code>MozSocial.getAttention()</code></a></dt> <dd> ユーザの注意を引くために設計されたいくつかのアクションを実行します。実際の動作はプラットフォームによって異なる場合があり、ヴィジュアル効果、音声通知、画面の点滅、または他のいくつかの技術が用いられる場合があります。</dd> <dt> <a href="/ja/docs/Web/API/MozSocial/getWorker" title="この項目についての文書はまだ書かれていません。書いてみませんか?"><code>MozSocial.getWorker()</code></a></dt> <dd> サービスワーカーへの参照を返します。コンテンツが一度この参照を持つと、サービスとの通信のために、<code>worker.port.postMessage()</code> メソッドを呼び出すことが可能となります。</dd> <dt> <a href="/ja/docs/Web/API/MozSocial/openChatWindow" title="この項目についての文書はまだ書かれていません。書いてみませんか?"><code>MozSocial.openChatWindow()</code></a></dt> <dd> ブラウザウィンドウの下部に固定されたチャットウィンドウを開きます。その機能は概ね個人チャットとなると考えられますが、提供者によって異なる場合があります。</dd> <dt> <a href="/ja/docs/Web/API/MozSocial/openPanel" title="この項目についての文書はまだ書かれていません。書いてみませんか?"><code>MozSocial.openPanel()</code></a></dt> <dd> 指定された垂直オフセットで、サイドバーに付属するフライアウトパネルを開きます。これは例えば、サイドバー通知に対応する実際の対話の表示に用いられます。</dd> </dl> <h2 id="See_also" name="See_also">関連情報</h2> <ul> <li><a href="/ja/docs/Social_API">Social API</a></li> </ul>
0
fastai/course22-web
2,574
Lessons/lesson8a.qmd
--- title: "Bonus: Data ethics" --- ::: {layout="[30,70]"} ![](../images/scales.png) Because deep learning is such a powerful tool and can be used for so many things, it becomes particularly important that we consider the consequences of our choices. The philosophical study of ethics is the study of right and wrong, including how we can define those terms, recognize right and wrong actions, and understand the connection between actions and consequences. ::: The field of data ethics has been around for a long time, and there are many academics focused on this field. It is being used to help define policy in many jurisdictions; it is being used in companies big and small to consider how best to ensure good societal outcomes from product development; and it is being used by researchers who want to make sure that the work they are doing is used for good, and not for bad. ## Video <iframe width="514" height="289" src="https://www.youtube-nocookie.com/embed/krIVOb23EH8?modestbranding=1" title="fast.ai lesson 9" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> This lesson, taught by Dr Rachel Thomas, the founding director of the Center for Applied Data Ethics at the University of San Francisco, was recorded in 2020 during the previous iteration of this course. It discusses some useful ways of thinking about data ethics, particularly through the lens of a number of case studies. It is based partly on [chapter 3](https://github.com/fastai/fastbook/blob/master/03_ethics.ipynb) of the [book](https://www.amazon.com/Deep-Learning-Coders-fastai-PyTorch/dp/1492045527). ## Useful links * [Datasheets for datasets](https://arxiv.org/abs/1803.09010) * [Weapons of math destruction](https://weaponsofmathdestructionbook.com/) * [AI Generated Faces](https://www.thispersondoesnotexist.com/) * [Papers/repos/tools on how to check for bias](https://forums.fast.ai/t/lesson-4-official-topic/68039/136?u=frapochetti) * [Markkula Center - Ethical Toolkit](https://www.scu.edu/ethics-in-technology-practice/ethical-toolkit/) * [The Pollyannish Assumption](https://stratechery.com/2017/the-pollyannish-assumption/) * [Understanding the context and consequences of pre-trial detention](https://facctconference.org/2018/livestream_vh210.html) * [Fast.ai community ethics resources & discussion](https://forums.fast.ai/t/ai-ml-ethics-biases-responsibility/45592) * [Montreal AI Ethics Institute Weekly Newsletter](https://aiethics.substack.com/p/ai-ethics-6-radioactive-data-attacking)
0
vanhoefm/libwifi
5,212
tests/test_dragonfly.py
from libwifi.dragonfly import * def test_crypto(): x = 32774075109236952337158599048510140249162039589740847669274255820096074575478 y = 65816200486131266053931191249788950977703402544735864608496951271815280382692 assert point_on_curve(x, y) assert not point_on_curve(x, y + 1) def test_sae(): # KDF_Length with 256 bits data = b'p(b\x08\x84%\xd4\xfc\x85\x02`>Z\x8e8\x02\x06\xdcak1_\x8a\xca\x90D2[\xda\x88\x87\xbe' label = "SAE Hunting and Pecking" context = b'\xff\xff\xff\xff\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' result = KDF_Length(data, label, context, 256) assert result == b"\xce\xd7\x0c`n\xc3\xa0V\xbc\xe5<Y\xd3\x80f@'.\xa3\xd8\x18\xedr\xd4/\xc8\x8a)\x18?G\xc4" # TODO: Test KDF_Length and derive_pwe_ecc with 521 bits # Needs one iteration pwe = derive_pwe_ecc("password", "01:02:03:04:05:06", "11:22:33:44:55:66") assert pwe.x == 93556404347856098254252288489266236507096062950733110787978910790160278833092 assert pwe.y == 78525808305378972147720640984042921538517312040012375950098621853813571375494 # Needs 4 iterations pwe = derive_pwe_ecc("OtherPassword4", "01:02:03:04:05:06", "11:22:33:44:55:66") assert pwe.x == 64608214587651293351943984050978725016684752726028646409621871614902214025509 assert pwe.y == 6010654006319004793785415601018381818802850726803703928480923751376254632130 def test_eappwd(): data = b'yKY2\xdfVP_\x84R\x04d\t\xa9\xac\xc0\xd0\x81\xe7\x01\xaa5\xe0\xd5r\xb6K\xb1g\xe0\xc8\xca' label = "EAP-pwd Hunting And Pecking" result = KDF_Length_eappwd(data, label, 256) assert result == b'\x82\xe7\x92\xd75\xfc\xef\x0e:\xb1\xea\x85E\xe6\rt\x849\xd6\xc3l\xcd\x00\x8e\xde\x94\xe4\xde\xa6q\x91\x1e' data = b'\xa8\xd5\x0c\xf47\x9b\xd0\x1d\x89\x1d\x1f\xf4\xa1\xeb\xdd\x9e\x17\x9d\xecm\xd8\xe6A2\x9c\xde$p\x9a\xcb\xd5N' result = KDF_Length_eappwd(data, label, 256) assert result == b'\xc8r\xfdke\xce\xfa\xbb\x0e\xc3\xb8\x83\xc2\x04\x95\x9fT\xc3P\xa9\x1be\x84\x16\xfba&\xc0!\xfbMs' data = binascii.unhexlify("8726279f4137e57cc040cc23bdf7053217dc613bae7defe2549c5bb75ad72a79") expect = binascii.unhexlify("ab8c540cf06cb38138670bb4e64b93d1f1232ae94f27bc19106bc84be6d0297bc2bf4b30418e12eed79462304bf12563a6b211984acf4c95005875f5b94d19c06400") result = KDF_Length_eappwd(data, label, 521) assert result == expect data = binascii.unhexlify("2683a19c41fd2ad1736f3efdccfee34afcd9866ee4e213b8e23d191f4ce5a4f7") expect = binascii.unhexlify("60d5d03a90e5ee8d08e1390f50b070330b4680dc8cf974e3227a8c09eedc56d975b191c7ea3ef5d0adcc0fa777bedcea9910098d3b02d1741699bfe8fa39be69a880") result = KDF_Length_eappwd(data, label, 521) assert result == expect data = b'\x82\x02\x07\xceX\xf5\xbb\x11s\xdc\xe4\xcb\xcc"\xa9\x1f\'\x19\xe0\xee\x84w\xb7\xd6G\xad\xa6w_\xf1\x8eg' label = b'4%\xfe\x8e\xd4\x93YD\xb3\xe7\xea\x8coN\xac\xf1 r\x83\x86u\xe1I\xbeS\xa7\x12l\xea\xbdhw\xc7' result = KDF_Length_eappwd(data, label, 1024) expected = b's\xdd\xb9\xcf]\x80\x08\xf6\xa08\xf1J L\x8d\xd5\xa9j\x83J\x9d\x04T(\x1a\xbc\x11o\xab\x015\x82V\xd8\xff>J' expected += b'\x80P\x1f[PB\xfaF\x13\xae\xef\xfd\xddBkX\xff\xe03\xd3q(\x80\x9f"S\xad\xfeK:\x98\x90\xde\xdfw' expected += b'\xd5\xe4\xf0O\xcf\x9c\xa1\r^\xf3\xf6\x1fp_\xd9\x13<\xf7\x0e\xf11\x81\x88\xb9\xfe\x80mn\xed\xf2' expected += b'\xdel\x8f8f\\\xd4\x91\x83}|\xd0\x90\xa6I\xac\xca\xdb\x1d4\x00\xf5\xf8\xf5/\xa1' assert result == expected k = 34571911558658786479991772754682275693090212979118519100150784653967632958583 e1x = 35056562182093533434520846036041768262744712948121085631797144112066231820275 e1y = 30178867311470377631935198005507521070028138958470370567962433403317268006022 e1 = ECC.EccPoint(e1x, e1y) s1 = 25673957538626389018921350300691255233489834439459044820849488820063961042178 e2x = 55846548926525467025361797152934092596912359473099878093027981331310692689958 e2y = 25540727936496301520339336932631497861346599764823572263118430938562903665071 e2 = ECC.EccPoint(e2x, e2y) s2 = 89671311642711662572527453485728796207545960881415665173397225314404138450610 confirm = calculate_confirm_eappwd(k, e1, s1, e2, s2) assert confirm == b"n\xe1N\xc1\x86\x0f\x94\x85W*Y\xf8\xf2'\x19\xac\x9c\xf6\xe6\xe6\x14\x8c+\xf7\x0e\xd0\xfdF\x87\x03G\xcc" pwe = derive_pwe_ecc_eappwd("password", "user", "server", 2903600207) assert pwe.x == 65324672961960968584356420288746215288928369435013474055323481826901726558522 assert pwe.y == 81287605691219879983190651062276165371083848816381214499332721121120114417256 pwe = derive_pwe_ecc_eappwd("password", "user", "server", 2546484939) assert pwe.x == 32774075109236952337158599048510140249162039589740847669274255820096074575478 assert pwe.y == 65816200486131266053931191249788950977703402544735864608496951271815280382692 pwe = derive_pwe_ecc_eappwd("hello", "bob", "[email protected]", 0xEE04524, curve_name="p521") assert pwe.x == 3008622341264366589487649162226557348235630833654679745848438214237061388319208914517686003128943873854271397962689455307621303688693893126759626682265352869 assert pwe.y == 649775647643090676911381912723346979966421674682002310678312738784243727860456911539411456724737204490685667258758093054491548052506429972664016924839683943
0
OCA/server-ux
6,294
date_range/tests/test_date_range_type.py
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl) from dateutil.relativedelta import relativedelta from dateutil.rrule import MONTHLY, YEARLY from psycopg2 import IntegrityError from odoo import fields from odoo.exceptions import UserError from odoo.tests.common import TransactionCase from odoo.tools import mute_logger class DateRangeTypeTest(TransactionCase): def setUp(self): super().setUp() self.type = self.env["date.range.type"] self.company = self.env["res.company"].create({"name": "Test company"}) self.company_2 = self.env["res.company"].create( {"name": "Test company 2", "parent_id": self.company.id} ) def test_default_company(self): drt = self.type.create({"name": "Fiscal year", "allow_overlap": False}) self.assertTrue(drt.company_id) # you can specify company_id to False drt = self.type.create( {"name": "Fiscal year", "company_id": False, "allow_overlap": False} ) self.assertFalse(drt.company_id) def test_unlink(self): date_range = self.env["date.range"] drt = self.env["date.range.type"].create( {"name": "Fiscal year", "allow_overlap": False} ) date_range.create( { "name": "FS2016", "date_start": "2015-01-01", "date_end": "2016-12-31", "type_id": drt.id, } ) with self.assertRaises(IntegrityError), mute_logger("odoo.sql_db"): drt.unlink() def test_type_multicompany(self): drt = self.type.create( {"name": "Fiscal year", "company_id": False, "allow_overlap": False} ) dr = self.env["date.range"].create( { "name": "FS2016", "date_start": "2015-01-01", "date_end": "2016-12-31", "type_id": drt.id, "company_id": self.company.id, } ) drt.company_id = self.company.id with self.assertRaises(UserError): dr.company_id = self.company_2 def test_autogeneration(self): """Ranges are autogenerated for types configured for that""" today = fields.Date.context_today(self.env.user) year_start = today.replace(day=1, month=1) dr_type = self.env["date.range.type"].create( { "name": __name__, "name_expr": "'>%s<' % date_start.strftime('%d%m%Y')", "unit_of_time": str(MONTHLY), "duration_count": 1, "autogeneration_count": 1, "autogeneration_unit": str(YEARLY), } ) self.assertEqual( dr_type.range_name_preview, f">{year_start.strftime('%d%m%Y')}<" ) self.env["date.range.type"].autogenerate_ranges() ranges = self.env["date.range"].search( [("type_id", "=", dr_type.id)], order="date_start asc" ) # For new types, ranges are autogenerated from the start of the year year_start = today.replace(day=1, month=1) self.assertEqual(ranges[0].date_start, year_start) # Ranges are autogenerated upto the range in which the computed end # date falls, c.q. the first of the month a year from now. next_year_month_start = today.replace(day=1) + relativedelta(years=1) self.assertEqual(ranges[-1].date_start, next_year_month_start) self.assertEqual( ranges[-1].name, f">{next_year_month_start.strftime('%d%m%Y')}<" ) # No new ranges get generated anymore this month self.env["date.range.type"].autogenerate_ranges() self.assertEqual( len(ranges), len( self.env["date.range"].search( [("type_id", "=", dr_type.id)], order="date_start asc" ) ), ) def test_autogeneration_with_start_date(self): today = fields.Date.context_today(self.env.user) start_date = today.replace(year=2019, day=6, month=1) dr_type = self.env["date.range.type"].create( { "name": __name__, "name_expr": "'>%s<' % date_start.strftime('%d%m%Y')", "unit_of_time": str(MONTHLY), "duration_count": 1, "autogeneration_date_start": start_date, "autogeneration_count": 1, "autogeneration_unit": str(YEARLY), } ) self.assertFalse(dr_type.date_ranges_exist) self.env["date.range.type"].autogenerate_ranges() self.assertTrue(dr_type.date_ranges_exist) ranges = self.env["date.range"].search( [("type_id", "=", dr_type.id)], order="date_start asc" ) self.assertEqual(ranges[0].date_start, start_date) # No new ranges get generated anymore this month self.env["date.range.type"].autogenerate_ranges() self.assertEqual( len(ranges), len( self.env["date.range"].search( [("type_id", "=", dr_type.id)], order="date_start asc" ) ), ) def test_autogeneration_invalid_config(self): """The cron method does not raise when an invalid config exists""" today = fields.Date.context_today(self.env.user) start_date = today.replace(year=2019, day=6, month=1) dr_type = self.env["date.range.type"].create( { "name": __name__, "name_expr": "index", "unit_of_time": str(MONTHLY), "duration_count": 1, "autogeneration_date_start": start_date, "autogeneration_count": 1, "autogeneration_unit": str(YEARLY), } ) # Inject invalid value self.env.cr.execute("UPDATE date_range_type SET name_expr = 'invalid'") dr_type.invalidate_model() with mute_logger("odoo.addons.date_range.models.date_range_type"): self.env["date.range.type"].autogenerate_ranges() self.assertFalse(dr_type.date_ranges_exist)
0
eclipse-iceoryx/iceoryx
5,196
iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/error_reporting/testing_error_handler.hpp
// Copyright (c) 2023 by Apex.AI Inc. All rights reserved. // Copyright (c) 2024 by ekxide IO GmbH. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 #ifndef IOX_HOOFS_TESTING_ERROR_REPORTING_TESTING_ERROR_HANDLER_HPP #define IOX_HOOFS_TESTING_ERROR_REPORTING_TESTING_ERROR_HANDLER_HPP #include "iox/atomic.hpp" #include "iox/error_reporting/custom/default/error_handler_interface.hpp" #include "iox/error_reporting/error_logging.hpp" #include "iox/error_reporting/source_location.hpp" #include "iox/error_reporting/types.hpp" #include "iox/error_reporting/violation.hpp" #include "iox/function_ref.hpp" #include "iox/static_lifetime_guard.hpp" #include "iceoryx_hoofs/testing/test.hpp" #include <vector> // we can use this for test code #include <mutex> // NOLINTNEXTLINE(hicpp-deprecated-headers) required to work on some platforms #include <setjmp.h> namespace iox { namespace testing { /// @brief Defines the test reaction of dynamic error handling. class TestingErrorHandler : public iox::er::ErrorHandlerInterface { public: TestingErrorHandler() noexcept = default; ~TestingErrorHandler() noexcept override = default; TestingErrorHandler(const TestingErrorHandler&) noexcept = delete; TestingErrorHandler(TestingErrorHandler&&) noexcept = delete; TestingErrorHandler& operator=(const TestingErrorHandler&) noexcept = delete; TestingErrorHandler operator=(TestingErrorHandler&&) noexcept = delete; /// @brief Initialized the error handler. This should be called in the main function of the test binary /// @code /// #include "iceoryx_hoofs/testing/error_reporting/testing_error_handler.hpp" /// /// #include "test.hpp" /// /// int main(int argc, char* argv[]) /// { /// ::testing::InitGoogleTest(&argc, argv); /// /// iox::testing::ErrorHandler::init(); /// /// return RUN_ALL_TESTS(); /// } /// @endcode static void init() noexcept; /// @brief Defines the reaction on panic. void onPanic() override; /// @brief Defines the reaction on error. /// @param desc error descriptor void onReportError(er::ErrorDescriptor desc) override; /// @brief Defines the reaction on violation. /// @param desc error descriptor void onReportViolation(er::ErrorDescriptor desc) override; /// @brief Indicates whether there was a panic call previously. /// @return true if there was a panic call, false otherwise bool hasPanicked() const noexcept; /// @brief Reset panic state and clears all errors that occurred previously. void reset() noexcept; /// @brief Indicates whether any error occurred previously. bool hasError() const noexcept; /// @brief Indicates whether a specific error occurred previously. bool hasError(iox::er::ErrorCode code, iox::er::ModuleId module = iox::er::ModuleId()) const noexcept; /// @brief Indicates whether a assumption violation occurred previously. /// @note We do not track module id for violations. bool hasViolation(iox::er::ErrorCode code) const noexcept; /// @brief runs testFunction in a test context that can detect fatal failures; /// runs in the same thread /// @note uses setjmp/longjmp bool fatalFailureTestContext(const function_ref<void()> testFunction); private: void jump() noexcept; private: static constexpr int JUMPED_INDICATOR{1}; mutable std::mutex m_mutex; iox::concurrent::Atomic<bool> m_panicked{false}; std::vector<er::ErrorDescriptor> m_errors; // we track violations separately (leads to simple search) std::vector<er::ErrorDescriptor> m_violations; // if we would like to support concurrent jumps it gets very tricky // and we would need multiple jump buffers jmp_buf m_jumpBuffer{}; enum class JumpState : uint8_t { Obtainable, Pending, }; // Actually not needed to be atomic since it is not supposed to be used from multiple threads // (longjmp does not support this) // We need to ensure though that only one jump buffer is considered by panic and controlling // ownership of the buffer is one way to accomplish that. iox::concurrent::Atomic<JumpState> m_jumpState{JumpState::Obtainable}; }; /// @brief This class hooks into gTest to automatically resets the error handler on the start of a test class ErrorHandlerSetup : public ::testing::EmptyTestEventListener { void OnTestStart(const ::testing::TestInfo&) override; }; using ErrorHandler = iox::StaticLifetimeGuard<iox::testing::TestingErrorHandler>; } // namespace testing } // namespace iox #endif
0
wudun7/UGuardMap
1,419
VisualUefi/edk2/CryptoPkg/Library/OpensslLib/openssl/test/ssltestlib.h
/* * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #ifndef HEADER_SSLTESTLIB_H # define HEADER_SSLTESTLIB_H # include <openssl/ssl.h> int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm, int min_proto_version, int max_proto_version, SSL_CTX **sctx, SSL_CTX **cctx, char *certfile, char *privkeyfile); int create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl, SSL **cssl, BIO *s_to_c_fbio, BIO *c_to_s_fbio); int create_ssl_connection(SSL *serverssl, SSL *clientssl); /* Note: Not thread safe! */ const BIO_METHOD *bio_f_tls_dump_filter(void); void bio_f_tls_dump_filter_free(void); const BIO_METHOD *bio_s_mempacket_test(void); void bio_s_mempacket_test_free(void); /* Packet types - value 0 is reserved */ #define INJECT_PACKET 1 #define INJECT_PACKET_IGNORE_REC_SEQ 2 int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum, int type); typedef struct mempacket_st MEMPACKET; DEFINE_STACK_OF(MEMPACKET) #endif /* HEADER_SSLTESTLIB_H */
0
Open-Turing-Project/OpenTuring
3,511
turing/tlib/TLCXOR.c
#include "include\cinterface" typedef TLnat4 TL_TL_priority_t; struct TL_TL_ExceptionInfo { TLint4 quitCode; TLint4 libraryQuitCode; TLstring errorMsg; }; typedef TLnat1 __x353[1]; struct TL_TL_HandlerArea { TLint4 quitCode; TLnat4 lineAndFile; TLaddressint fileTable; struct TL_TL_HandlerArea *nextHandler; __x353 savedState; }; typedef TLnat4 TL_TL_hardwarePriority_t; typedef TL_TL_hardwarePriority_t TL_TL_lockStatus_t; typedef TLnat4 TL_TL_lock_t; struct TL_TL_link_t { struct TL_TL_ProcessDescriptor *flink; struct TL_TL_ProcessDescriptor *blink; }; struct TL_TL_ProcessDescriptor { TLnat4 lineAndFile; TLaddressint fileTable; TLaddressint stackLimit; TLaddressint stackPointer; struct TL_TL_HandlerArea *handlerQhead; struct TL_TL_HandlerArea *currentHandler; TLaddressint name; struct TL_TL_ExceptionInfo exception; TLnat4 waitParameter; struct TL_TL_ProcessDescriptor *monitorQlink; TLnat4 timeOutStatus; TLnat4 pid; TLaddressint memoryBase; TLnat4 timeoutTime; TLnat4 timeoutEpoch; struct TL_TL_link_t timeoutQ; TLboolean timedOut; TLboolean pausing; TL_TL_priority_t dispatchPriority; struct TL_TL_ProcessDescriptor *runQlink; TLboolean ready; struct TL_TL_ProcessDescriptor *tsyncWaiter; TLnat4 quantum; TLnat4 quantumCntr; TLnat4 devmonLevel; TLaddressint otherInfo; }; extern void TL_TLM_TLMUDUMP (); extern void TL_TLB_TLBMAL (); extern void TL_TLB_TLBMFR (); extern void TL_TLB_TLBNWU (); extern void TL_TLB_TLBFRU (); extern void TL_TLI_TLIFS (); extern void TL_TLI_TLIAON (); extern void TL_TLI_TLIAOFF (); extern void TL_TLI_TLIUDUMP (); extern void TL_TLI_TLIFINI (); extern void TL_TLE_TLELF (); typedef TLint4 TL_Cint; extern TLboolean TL_TLECU; extern struct TL_TL_ProcessDescriptor *TL_TLKPD; void TL_TLQUIT (); extern void TL_TLK_TLKINI (); extern void TL_TLK_TLKFINI (); extern void TL_TLK_TLKUXRS (); extern void TL_TLK_TLKUXRE (); extern void TL_TLK_TLKUEXIT (); extern void TL_TLK_TLKUDMPP (); extern void TL_TLK_TLKPFORK (); extern TLboolean TL_TLK_TLKFRKED (); extern void TL_TLK_TLKLKON (); extern void TL_TLK_TLKLKOFF (); extern void TL_TLK_TLKSSYNC (); extern void TL_TLK_TLKSWAKE (); extern void TL_TLK_TLKSTIMO (); extern void TL_TLK_TLKCINI (); extern TLnat4 TL_TLK_TLKPGETP (); extern void TL_TLK_TLKPSETP (); extern void TL_TLK_TLKIPINI (); extern void TL_TLK_TLKIPENT (); extern void TL_TLK_TLKIPEXT (); extern TLboolean TL_TLK_TLKDMINI (); extern void TL_TLK_TLKDMENT (); extern void TL_TLK_TLKDMEXT (); extern void TL_TLK_TLKPPAUS (); extern void TL_TLX_TLXPID (); extern void TL_TLX_TLXTIM (); extern void TL_TLX_TLXATF (); extern void TL_TLX_TLXDT (); extern void TL_TLX_TLXTM (); extern void TL_TLX_TLXCL (); extern void TL_TLX_TLXSC (); extern void TL_TLX_TLXGE (); extern void TL_TLX_TLXSYS (); void TL_TLC_TLCXOR (res, sl, sr, ssize) TLaddressint res; TLaddressint sl; TLaddressint sr; TLint4 ssize; { register TLaddressint dst; register TLaddressint srcl; register TLaddressint srcr; dst = (TLaddressint) res; srcl = (TLaddressint) sl; srcr = (TLaddressint) sr; { register TLint4 __x352; TLint4 __x356; __x356 = ssize; __x352 = 1; if (__x352 <= __x356) { for(;;) { (* (TLnat1 *) dst) = ((* (TLnat1 *) srcl)) ^ ((* (TLnat1 *) srcr)); dst += 1; srcr += 1; srcl += 1; if (__x352 == __x356) break; __x352++; } }; }; }
0
vityabond/hopebilling
11,235
app/modules/billmanagervps/billmanagervps.php
<?php namespace modules\billmanagervps; use email\Email; use model\Bill; use model\Client; use model\ServiceCategories; use modules\billmanagervps\classes\BillManagerAPI; use modules\billmanagervps\classes\model\Order; use modules\billmanagervps\classes\model\Plan; use sms\SMS; use System\Config; use System\Cookie; use System\Db\Db; use System\Db\Schema\Schema; use System\Db\Schema\Table; use System\Notifier; use System\Tools; use System\View\View; class billmanagervps extends \System\Module { public $name = 'Ресселинг VPS (BillManager API)'; public $author = '<a target="_blank" href="http://hopebilling.com">hopebilling.com</a>'; public $paid = false; public function actionSetting() { $config = new Config('billmanagervps.module'); if (Tools::rPOST()) { $config->url = Tools::rPOST('url'); $config->username = Tools::rPOST('username'); $config->password = Tools::rPOST('password'); $config->save(); } $view = $this->getModuleView('setting.php', 'admin'); $view->bconfig = $config; return $view; } public function install() { $this->registerHook('getFrontLayoutMenu'); $this->registerHook('getAdminLayoutMenu'); $this->registerHook('payBill'); $this->registerHook('dailyCronUpdate'); $this->registerHook('getListServicesForBills'); $this->registerHook('getListBills'); $this->registerHook('afterGetListBills'); Schema::create('billmanagervps_plans', function (Table $t) { $t ->increment('id') ->string('name') ->string('link') ->float('price') ->int('pricelist') ->text('description') ->int('price_id') ->int('period_id') ->text('additions') ->text('templates') ->create(); }); Schema::create('billmanagervps_orders', function (Table $t) { $t ->increment('id') ->int('plan_id') ->int('client_id') ->int('billorder_id') ->int('order_id') ->bool('active') ->text('ostempl') ->string('username') ->string('userpassword') ->string('password') ->string('domain') ->string('ip') ->bool('notified') ->date('paid_to') ->create(); }); return parent::install(); // TODO: Change the autogenerated stub } public function uninstall() { Schema::drop('billmanagervps_plans'); Schema::drop('billmanagervps_orders'); $config = new Config('billmanagervps.module'); $config->remove(); $billObject = new Bill(); $billObject->where('type', 101)->removeRows(); return parent::uninstall(); // TODO: Change the autogenerated stub } public function getAdminLayoutMenu(&$menu) { $menu['services'][] = (object)[ 'link' => Tools::link('modules/billmanagervps/orders'), 'name' => 'Billmanager VDS', 'icon' => 'fa-server', 'items' => [ (object)['link' => Tools::link('admin/modules/billmanagervps/orders'), 'name' => 'Заказы', 'icon' => 'glyphicon-shopping-cart'], (object)['link' => Tools::link('admin/modules/billmanagervps/plans'), 'name' => 'Тарифы', 'icon' => 'glyphicon-stats'], ] ]; } public function getFrontLayoutMenu(&$menu) { $menu['orders'][] = (object)['link' => Tools::link('modules/billmanagervps/orders'), 'name' => 'VPS', 'icon' => 'glyphicon glyphicon-hdd']; $menu['create_orders'][] = (object)['link' => Tools::link('modules/billmanagervps/order/new'), 'name' => 'VPS', 'icon' => 'glyphicon glyphicon-hdd']; } /** * @param $billObject */ public function payBill(&$billObject) { if ($billObject->is_paid && $billObject->type == 101) { $config = new Config('billmanagervps.module'); $billManager = new BillManagerAPI($config->url, $config->username, $config->password); $orderObject = new Order($billObject->hosting_account_id); if (!$orderObject->billorder_id) { $planObject = new Plan($orderObject->plan_id); $addons = $planObject->additions; $addons = explode(PHP_EOL, $addons); $addons_formed = []; foreach ($addons as $addon) { $res = explode('=', $addon); $addons_formed[$res[0]] = $res[1]; } $order = $billManager->createVds($planObject->pricelist, $billObject->pay_period, $orderObject->ostempl, $addons_formed, $orderObject->domain); if ($order) { $orderObject->billorder_id = $order['billorder_id']; $orderObject->order_id = $order['order_id']; $orderObject->paid_to = date('Y-m-d', strtotime($orderObject->paid_to) + Cookie::ONE_MONAT * $billObject->pay_period); $orderObject->active = 1; $orderObject->save(); $billManager->payVds($orderObject->billorder_id); $clientObject = new Client($orderObject->client_id); $view = $this->getModuleView('admin/order/new.php', 'sms');; $view2 = $this->getModuleView('order/new.php', 'sms');; SMS::getGateway()->sendSMS($clientObject->phone, $view2->fetch()); SMS::getGateway()->sendSMS($config->site_sms, $view->fetch()); } } else if ($orderObject->isLoadedObject()) { if (!$orderObject->active) { $billManager->resumeVds($orderObject->order_id); $orderObject->active = 1; } $orderObject->paid_to = date('Y-m-d', strtotime($orderObject->paid_to) + Cookie::ONE_MONAT * $billObject->pay_period); $orderObject->save(); } } } public function getListServicesForBills(&$services) { $services['module_101'] = 'VPS'; } public function getListBills($moduleDate) { $filter = Tools::rPOST('filter'); $billObject = $moduleDate['billObject']; if ($filter['type']['value'] == 'module_101') { $billObject->where('type', 101); } $view = $moduleDate['view']; if (Tools::rGET('id_order_billmanager')) { $view->order = new Order(Tools::rGET('id_order_billmanager')); $billObject->where('hosting_account_id', '=', Tools::rGET('id_order_billmanager')); } } public function afterGetListBills(&$bills) { $plans = []; foreach ($bills as &$bill) { if ($bill->type == 101) { if (!isset($plans[$bill->hosting_account_id])) { $orderObject = new Order($bill->hosting_account_id); $planObject = new Plan($orderObject->plan_id); $plans[$bill->hosting_account_id] = $planObject; } $planObject = $plans[$bill->hosting_account_id]; $bill->plan = $planObject->name; } } } public function dailyCronUpdate() { $VpsOrder = new Order(); $vps_orders = $VpsOrder->getRows(); foreach ($vps_orders as $vps_order) { $VpsOrder = new Order($vps_order); $time_now = time(); $now = date('Y-m-d'); $account_paid = $VpsOrder->paid_to; $account_paid = strtotime($account_paid); $client = new Client($VpsOrder->client_id); if ($VpsOrder->active && ($account_paid - $time_now < 86400 * 3) && ($account_paid - $time_now) >= 0) { $time = $account_paid - $time_now; $days = ceil($time / (60 * 60 * 24)); $bill = new \model\Bill(); $res = $bill ->where('type', Bill::TYPE_ORDER) ->where('hosting_account_id', $VpsOrder->id) ->where('client_id', $VpsOrder->client_id) ->where('is_paid', 0)->getRow(); if (!($res)) { $bill = new \model\Bill(); $plan = new \model\VpsPlan($VpsOrder->plan_id); $bill->hosting_account_id = $VpsOrder->id; $bill->is_paid = 0; $bill->client_id = $VpsOrder->client_id; $bill->type = 101; $bill->pay_period = 1; $bill->hosting_plan_id = $plan->id; $bill->price = $plan->price; $bill->total = $plan->price; $bill->date = date('Y-m-d'); if ($bill->save()) { } } } //echo time().' -- '.$account_paid. '<br>'; $config = new Config('billmanagervps.module'); $billManager = new BillManagerAPI($config->url, $config->username, $config->password); if (time() >= $account_paid && $VpsOrder->active == 1) { $VpsOrder->active = 0; $billManager->suspendVds($VpsOrder->order_id); $clientObject = new Client($VpsOrder->client_id); $email = new Email(); $email->to = $clientObject->email; $eview = $this->getModuleView('order/suspend.php', 'email'); $eview->order = $VpsOrder; $email->msg = $eview->fetch(); $email->send(); $view = $this->getModuleView('admin/order/suspend.php', 'sms'); $view2 = $this->getModuleView('order/suspend.php', 'sms');; SMS::getGateway()->sendSMS($clientObject->phone, $view2->fetch()); SMS::getGateway()->sendSMS($config->site_sms, $view->fetch()); $VpsOrder->save(); } else if ($VpsOrder->active == 0 && time() < $account_paid) { $VpsOrder->active = 1; $billManager->resumeVds($VpsOrder->order_id); $clientObject = new Client($VpsOrder->client_id); $email = new Email(); $email->to = $clientObject->email; $eview = $this->getModuleView('order/unsuspend.php', 'email'); $eview->order = $VpsOrder; $email->msg = $eview->fetch(); $email->send(); $view = $this->getModuleView('admin/order/unsuspend.php', 'sms');; $view2 = $this->getModuleView('order/unsuspend.php', 'sms');; SMS::getGateway()->sendSMS($clientObject->phone, $view2->fetch()); SMS::getGateway()->sendSMS($config->site_sms, $view->fetch()); $VpsOrder->save(); } } } }
0
Vonage/vonage-dotnet-sdk
2,938
Vonage.Test/Users/CreateUser/E2ETest.cs
#region using System; using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using Vonage.Test.Common.Extensions; using Vonage.Users; using Vonage.Users.CreateUser; using WireMock.ResponseBuilders; using Xunit; #endregion namespace Vonage.Test.Users.CreateUser; [Trait("Category", "E2E")] public class E2ETest() : E2EBase(typeof(E2ETest).Namespace) { [Fact] public async Task CreateEmptyUser() { this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() .WithPath("/v1/users") .WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue) .WithBody(this.Serialization.GetRequestJson(nameof(SerializationTest.ShouldSerializeEmpty))) .UsingPost()) .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK) .WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200)))); await this.Helper.VonageClient.UsersClient .CreateUserAsync(CreateUserRequest .Build() .Create()) .Should() .BeSuccessAsync(VerifyUser); } [Fact] public async Task CreateUser() { this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() .WithPath("/v1/users") .WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue) .WithBody(this.Serialization.GetRequestJson(nameof(SerializationTest.ShouldSerialize))) .UsingPost()) .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK) .WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200)))); await this.Helper.VonageClient.UsersClient .CreateUserAsync(CreateUserRequest .Build() .WithName("my_user_name") .WithDisplayName("My User Name") .WithImageUrl(new Uri("https://example.com/image.png")) .WithUserProperty("custom_key", "custom_value") .WithChannel(new ChannelPstn(123457)) .WithChannel(new ChannelSip("sip:[email protected];transport=tls", "New SIP", "Password")) .WithChannel(new ChannelVbc("403")) .WithChannel(new ChannelWebSocket("wss://example.com/socket", "audio/l16;rate=16000", new Dictionary<string, string> {{"customer_id", "ABC123"}})) .WithChannel(new ChannelSms("447700900000")) .WithChannel(new ChannelMms("447700900000")) .WithChannel(new ChannelWhatsApp("447700900000")) .WithChannel(new ChannelViber("447700900000")) .WithChannel(new ChannelMessenger("12345abcd")) .Create()) .Should() .BeSuccessAsync(VerifyUser); } }
0
projectlombok/lombok
60,815
src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
/* * Copyright (C) 2013-2025 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package lombok.eclipse.handlers; import static lombok.eclipse.handlers.HandleBuilder.*; import static lombok.core.handlers.HandlerUtil.*; import static lombok.eclipse.Eclipse.*; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Argument; import org.eclipse.jdt.internal.compiler.ast.Assignment; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression; import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; import org.eclipse.jdt.internal.compiler.ast.EqualExpression; import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.FalseLiteral; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import org.eclipse.jdt.internal.compiler.ast.FieldReference; import org.eclipse.jdt.internal.compiler.ast.IfStatement; import org.eclipse.jdt.internal.compiler.ast.Initializer; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.NullLiteral; import org.eclipse.jdt.internal.compiler.ast.OperatorIds; import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference; import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference; import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.eclipse.jdt.internal.compiler.ast.Statement; import org.eclipse.jdt.internal.compiler.ast.SuperReference; import org.eclipse.jdt.internal.compiler.ast.ThisReference; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeParameter; import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.ast.Wildcard; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; import org.eclipse.jdt.internal.compiler.lookup.MethodScope; import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import lombok.AccessLevel; import lombok.Builder; import lombok.Builder.ObtainVia; import lombok.ConfigurationKeys; import lombok.Singular; import lombok.ToString; import lombok.core.AST.Kind; import lombok.core.configuration.CheckerFrameworkVersion; import lombok.core.handlers.HandlerUtil; import lombok.core.handlers.InclusionExclusionUtils.Included; import lombok.core.AnnotationValues; import lombok.core.HandlerPriority; import lombok.eclipse.Eclipse; import lombok.eclipse.EclipseAnnotationHandler; import lombok.eclipse.EclipseNode; import lombok.eclipse.handlers.EclipseHandlerUtil.CopyJavadoc; import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult; import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer; import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData; import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker; import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker; import lombok.eclipse.handlers.HandleBuilder.BuilderFieldData; import lombok.eclipse.handlers.HandleBuilder.BuilderJob; import lombok.experimental.NonFinal; import lombok.experimental.SuperBuilder; import lombok.spi.Provides; @Provides @HandlerPriority(-1024) //-2^10; to ensure we've picked up @FieldDefault's changes (-2048) but @Value hasn't removed itself yet (-512), so that we can error on presence of it on the builder classes. public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { private static final char[] SELF_METHOD_NAME = "self".toCharArray(); private static final char[] FILL_VALUES_METHOD_NAME = "$fillValuesFrom".toCharArray(); private static final char[] FILL_VALUES_STATIC_METHOD_NAME = "$fillValuesFromInstanceIntoBuilder".toCharArray(); private static final char[] INSTANCE_VARIABLE_NAME = "instance".toCharArray(); private static final String BUILDER_VARIABLE_NAME_STRING = "b"; private static final char[] BUILDER_VARIABLE_NAME = BUILDER_VARIABLE_NAME_STRING.toCharArray(); class SuperBuilderJob extends BuilderJob { void init(AnnotationValues<SuperBuilder> annValues, SuperBuilder ann, EclipseNode node) { accessOuters = accessInners = AccessLevel.PUBLIC; oldFluent = true; oldChain = true; builderMethodName = ann.builderMethodName(); buildMethodName = ann.buildMethodName(); toBuilder = ann.toBuilder(); if (builderMethodName == null) builderMethodName = "builder"; if (buildMethodName == null) buildMethodName = "build"; builderClassName = getBuilderClassNameTemplate(node, null); } EclipseNode builderAbstractType; String builderAbstractClassName; char[] builderAbstractClassNameArr; EclipseNode builderImplType; String builderImplClassName; char[] builderImplClassNameArr; private TypeParameter[] builderTypeParams_; void setBuilderToImpl() { builderType = builderImplType; builderClassName = builderImplClassName; builderClassNameArr = builderImplClassNameArr; builderTypeParams = typeParams; } void setBuilderToAbstract() { builderType = builderAbstractType; builderClassName = builderAbstractClassName; builderClassNameArr = builderAbstractClassNameArr; builderTypeParams = builderTypeParams_; } } @Override public void handle(AnnotationValues<SuperBuilder> annotation, Annotation ast, EclipseNode annotationNode) { handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.SUPERBUILDER_FLAG_USAGE, "@SuperBuilder"); SuperBuilderJob job = new SuperBuilderJob(); job.sourceNode = annotationNode; job.source = ast; job.checkerFramework = getCheckerFrameworkVersion(annotationNode); job.isStatic = true; SuperBuilder annInstance = annotation.getInstance(); job.init(annotation, annInstance, annotationNode); boolean generateBuilderMethod; if (job.builderMethodName.isEmpty()) generateBuilderMethod = false; else if (!checkName("builderMethodName", job.builderMethodName, annotationNode)) return; else generateBuilderMethod = true; if (!checkName("buildMethodName", job.buildMethodName, annotationNode)) return; EclipseNode parent = annotationNode.up(); job.builderFields = new ArrayList<BuilderFieldData>(); TypeReference buildMethodReturnType; boolean addCleaning = false; List<EclipseNode> nonFinalNonDefaultedFields = null; if (!isClass(parent)) { annotationNode.addError("@SuperBuilder is only supported on classes."); return; } if (!isStaticAllowed(parent)) { annotationNode.addError("@SuperBuilder is not supported on non-static nested classes."); return; } job.parentType = parent; TypeDeclaration td = (TypeDeclaration) parent.get(); // Gather all fields of the class that should be set by the builder. List<EclipseNode> allFields = new ArrayList<EclipseNode>(); boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation("lombok.experimental.Value", parent)); for (EclipseNode fieldNode : HandleConstructor.findAllFields(parent, true)) { FieldDeclaration fd = (FieldDeclaration) fieldNode.get(); EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode); boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode)); Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode); BuilderFieldData bfd = new BuilderFieldData(); bfd.rawName = fieldNode.getName().toCharArray(); bfd.name = removePrefixFromField(fieldNode); bfd.builderFieldName = bfd.name; bfd.annotations = copyAnnotations(fd, copyableAnnotations); bfd.type = fd.type; bfd.singularData = getSingularData(fieldNode, ast, annInstance.setterPrefix()); bfd.originalFieldNode = fieldNode; if (bfd.singularData != null && isDefault != null) { isDefault.addError("@Builder.Default and @Singular cannot be mixed."); isDefault = null; } if (fd.initialization == null && isDefault != null) { isDefault.addWarning("@Builder.Default requires an initializing expression (' = something;')."); isDefault = null; } if (fd.initialization != null && isDefault == null) { if (isFinal) continue; if (nonFinalNonDefaultedFields == null) nonFinalNonDefaultedFields = new ArrayList<EclipseNode>(); nonFinalNonDefaultedFields.add(fieldNode); } if (isDefault != null) { bfd.nameOfDefaultProvider = prefixWith(DEFAULT_PREFIX, bfd.name); bfd.nameOfSetFlag = prefixWith(bfd.name, SET_PREFIX); bfd.builderFieldName = prefixWith(bfd.name, VALUE_PREFIX); MethodDeclaration md = HandleBuilder.generateDefaultProvider(bfd.nameOfDefaultProvider, td.typeParameters, fieldNode, ast); if (md != null) injectMethod(parent, md); } addObtainVia(bfd, fieldNode); job.builderFields.add(bfd); allFields.add(fieldNode); } job.typeParams = td.typeParameters != null ? td.typeParameters : new TypeParameter[0]; buildMethodReturnType = job.createBuilderParentTypeReference(); // <C, B> are the generics for our builder. String classGenericName = "C"; String builderGenericName = "B"; // We have to make sure that the generics' names do not collide with any generics on the annotated class, // the classname itself, or any member type name of the annotated class. // For instance, if there are generics <B, B2, C> on the annotated class, use "C2" and "B3" for our builder. java.util.Set<String> usedNames = gatherUsedTypeNames(job.typeParams, td); classGenericName = generateNonclashingNameFor(classGenericName, usedNames); builderGenericName = generateNonclashingNameFor(builderGenericName, usedNames); TypeParameter[] paddedTypeParameters; { paddedTypeParameters = new TypeParameter[job.typeParams.length + 2]; System.arraycopy(job.typeParams, 0, paddedTypeParameters, 0, job.typeParams.length); TypeParameter c = new TypeParameter(); c.name = classGenericName.toCharArray(); c.type = cloneSelfType(job.parentType, job.source); paddedTypeParameters[paddedTypeParameters.length - 2] = c; TypeParameter b = new TypeParameter(); b.name = builderGenericName.toCharArray(); b.type = cloneSelfType(job.parentType, job.source); paddedTypeParameters[paddedTypeParameters.length - 1] = b; } job.builderTypeParams = job.builderTypeParams_ = paddedTypeParameters; TypeReference extendsClause = td.superclass; TypeReference superclassBuilderClass = null; TypeReference[] typeArguments = new TypeReference[] { new SingleTypeReference(classGenericName.toCharArray(), 0), new SingleTypeReference(builderGenericName.toCharArray(), 0), }; if (extendsClause instanceof QualifiedTypeReference) { QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference)extendsClause; char[] superclassClassName = qualifiedTypeReference.getLastToken(); String builderClassNameTemplate = BuilderJob.getBuilderClassNameTemplate(annotationNode, null); String superclassBuilderClassName = job.replaceBuilderClassName(superclassClassName, builderClassNameTemplate); char[][] tokens = Arrays.copyOf(qualifiedTypeReference.tokens, qualifiedTypeReference.tokens.length + 1); tokens[tokens.length-1] = superclassBuilderClassName.toCharArray(); long[] poss = new long[tokens.length]; Arrays.fill(poss, job.getPos()); TypeReference[] superclassTypeArgs = getTypeParametersFrom(extendsClause); // Every token may potentially have type args. Here, we only have // type args for the last token, the superclass' builder. TypeReference[][] typeArgsForTokens = new TypeReference[tokens.length][]; typeArgsForTokens[typeArgsForTokens.length-1] = mergeTypeReferences(superclassTypeArgs, typeArguments); superclassBuilderClass = new ParameterizedQualifiedTypeReference(tokens, typeArgsForTokens, 0, poss); } else if (extendsClause != null) { char[] superclassClassName = extendsClause.getTypeName()[0]; String builderClassNameTemplate = BuilderJob.getBuilderClassNameTemplate(annotationNode, null); String superclassBuilderClassName = job.replaceBuilderClassName(superclassClassName, builderClassNameTemplate); char[][] tokens = new char[][] {superclassClassName, superclassBuilderClassName.toCharArray()}; long[] poss = new long[tokens.length]; Arrays.fill(poss, job.getPos()); TypeReference[] superclassTypeArgs = getTypeParametersFrom(extendsClause); // Every token may potentially have type args. Here, we only have // type args for the last token, the superclass' builder. TypeReference[][] typeArgsForTokens = new TypeReference[tokens.length][]; typeArgsForTokens[typeArgsForTokens.length-1] = mergeTypeReferences(superclassTypeArgs, typeArguments); superclassBuilderClass = new ParameterizedQualifiedTypeReference(tokens, typeArgsForTokens, 0, poss); } job.builderAbstractClassName = job.builderClassName = job.replaceBuilderClassName(td.name); job.builderAbstractClassNameArr = job.builderClassNameArr = job.builderAbstractClassName.toCharArray(); job.builderImplClassName = job.builderAbstractClassName + "Impl"; job.builderImplClassNameArr = job.builderImplClassName.toCharArray(); // If there is no superclass, superclassBuilderClassExpression is still == null at this point. // You can use it to check whether to inherit or not. if (!constructorExists(parent, job.builderClassName)) { generateBuilderBasedConstructor(job, superclassBuilderClass != null); } // Create the abstract builder class, or reuse an existing one. job.builderAbstractType = findInnerClass(parent, job.builderClassName); if (job.builderAbstractType == null) { job.builderAbstractType = generateBuilderAbstractClass(job, superclassBuilderClass, classGenericName, builderGenericName); } else { TypeDeclaration builderTypeDeclaration = (TypeDeclaration) job.builderAbstractType.get(); if ((builderTypeDeclaration.modifiers & (ClassFileConstants.AccStatic | ClassFileConstants.AccAbstract)) == 0) { annotationNode.addError("Existing Builder must be an abstract static inner class."); return; } sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderAbstractType, annotationNode); // Generate errors for @Singular BFDs that have one already defined node. for (BuilderFieldData bfd : job.builderFields) { SingularData sd = bfd.singularData; if (sd == null) continue; EclipseSingularizer singularizer = sd.getSingularizer(); if (singularizer == null) continue; if (singularizer.checkForAlreadyExistingNodesAndGenerateError(job.builderAbstractType, sd)) bfd.singularData = null; } } // Check validity of @ObtainVia fields, and add check if adding cleaning for @Singular is necessary. for (BuilderFieldData bfd : job.builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { if (bfd.singularData.getSingularizer().requiresCleaning()) { addCleaning = true; break; } } if (bfd.obtainVia != null) { if (bfd.obtainVia.field().isEmpty() == bfd.obtainVia.method().isEmpty()) { bfd.obtainViaNode.addError("The syntax is either @ObtainVia(field = \"fieldName\") or @ObtainVia(method = \"methodName\")."); return; } if (bfd.obtainVia.method().isEmpty() && bfd.obtainVia.isStatic()) { bfd.obtainViaNode.addError("@ObtainVia(isStatic = true) is not valid unless 'method' has been set."); return; } } } // Generate the fields in the abstract builder class that hold the values for the instance. job.setBuilderToAbstract(); generateBuilderFields(job); if (addCleaning) { FieldDeclaration cleanDecl = new FieldDeclaration(CLEAN_FIELD_NAME, 0, -1); cleanDecl.declarationSourceEnd = -1; cleanDecl.modifiers = ClassFileConstants.AccPrivate; cleanDecl.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0); injectFieldAndMarkGenerated(job.builderType, cleanDecl); } if (job.toBuilder) { // Generate $fillValuesFrom() method in the abstract builder. injectMethod(job.builderType, generateFillValuesMethod(job, superclassBuilderClass != null, builderGenericName, classGenericName)); // Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class. injectMethod(job.builderType, generateStaticFillValuesMethod(job, annInstance.setterPrefix())); } // Create the setter methods in the abstract builder. for (BuilderFieldData bfd : job.builderFields) { generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); } // Generate abstract self() and build() methods in the abstract builder. injectMethod(job.builderType, generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName)); job.setBuilderToAbstract(); injectMethod(job.builderType, generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName)); // Create the toString() method for the abstract builder. if (methodExists("toString", job.builderType, 0) == MemberExistsResult.NOT_EXISTS) { List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>(); for (BuilderFieldData bfd : job.builderFields) { for (EclipseNode f : bfd.createdFields) { fieldNodes.add(new Included<EclipseNode, ToString.Include>(f, null, true, false)); } } // Let toString() call super.toString() if there is a superclass, so that it also shows fields from the superclass' builder. MethodDeclaration md = HandleToString.createToString(job.builderType, fieldNodes, true, superclassBuilderClass != null, ast, FieldAccess.ALWAYS_FIELD); if (md != null) injectMethod(job.builderType, md); } if (addCleaning) { job.setBuilderToAbstract(); injectMethod(job.builderType, generateCleanMethod(job)); } boolean isAbstract = (td.modifiers & ClassFileConstants.AccAbstract) != 0; if (isAbstract) { // Only non-abstract classes get the Builder implementation. return; } // Create the builder implementation class, or reuse an existing one. job.builderImplType = findInnerClass(parent, job.builderImplClassName); if (job.builderImplType == null) { job.builderImplType = generateBuilderImplClass(job, job.builderImplClassName); } else { TypeDeclaration builderImplTypeDeclaration = (TypeDeclaration) job.builderImplType.get(); if ((builderImplTypeDeclaration.modifiers & ClassFileConstants.AccAbstract) != 0 || (builderImplTypeDeclaration.modifiers & ClassFileConstants.AccStatic) == 0) { annotationNode.addError("Existing BuilderImpl must be a non-abstract static inner class."); return; } sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderImplType, annotationNode); } job.setBuilderToImpl(); if (job.toBuilder) { // Add the toBuilder() method to the annotated class. switch (methodExists(TO_BUILDER_METHOD_NAME_STRING, job.parentType, 0)) { case EXISTS_BY_USER: break; case NOT_EXISTS: injectMethod(parent, generateToBuilderMethod(job)); break; default: // Should not happen. } } // Create the self() and build() methods in the BuilderImpl. job.setBuilderToImpl(); injectMethod(job.builderImplType, generateSelfMethod(job)); if (methodExists(job.buildMethodName, job.builderImplType, -1) == MemberExistsResult.NOT_EXISTS) { job.setBuilderToImpl(); injectMethod(job.builderImplType, generateBuildMethod(job, buildMethodReturnType)); } // Add the builder() method to the annotated class. if (generateBuilderMethod && methodExists(job.builderMethodName, parent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false; if (generateBuilderMethod) { MethodDeclaration md = generateBuilderMethod(job); if (md != null) injectMethod(parent, md); } if (nonFinalNonDefaultedFields != null && generateBuilderMethod) { for (EclipseNode fieldNode : nonFinalNonDefaultedFields) { fieldNode.addWarning("@SuperBuilder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final."); } } } private EclipseNode generateBuilderAbstractClass(BuilderJob job, TypeReference superclassBuilderClass, String classGenericName, String builderGenericName) { TypeDeclaration parent = (TypeDeclaration) job.parentType.get(); TypeDeclaration builder = new TypeDeclaration(parent.compilationResult); builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; builder.modifiers |= ClassFileConstants.AccPublic | ClassFileConstants.AccStatic | ClassFileConstants.AccAbstract; builder.name = job.builderClassNameArr; // Keep any type params of the annotated class. builder.typeParameters = Arrays.copyOf(copyTypeParams(job.typeParams, job.source), job.typeParams.length + 2); // Add builder-specific type params required for inheritable builders. // 1. The return type for the build() method, named "C", which extends the annotated class. TypeParameter o = new TypeParameter(); o.name = classGenericName.toCharArray(); o.type = cloneSelfType(job.parentType, job.source); builder.typeParameters[builder.typeParameters.length - 2] = o; // 2. The return type for all setter methods, named "B", which extends this builder class. o = new TypeParameter(); o.name = builderGenericName.toCharArray(); TypeReference[] typerefs = appendBuilderTypeReferences(job.typeParams, classGenericName, builderGenericName); o.type = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, typerefs, 0); builder.typeParameters[builder.typeParameters.length - 1] = o; if (superclassBuilderClass != null) builder.superclass = copyType(superclassBuilderClass, job.source); builder.createDefaultConstructor(false, true); builder.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null); return injectType(job.parentType, builder); } private EclipseNode generateBuilderImplClass(BuilderJob job, String builderImplClass) { TypeDeclaration parent = (TypeDeclaration) job.parentType.get(); TypeDeclaration builder = new TypeDeclaration(parent.compilationResult); builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; builder.modifiers |= ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal; builder.name = builderImplClass.toCharArray(); // Add type params if there are any. if (job.typeParams != null && job.typeParams.length > 0) builder.typeParameters = copyTypeParams(job.typeParams, job.source); if (job.builderClassName != null) { // Extend the abstract builder. // 1. Add any type params of the annotated class. TypeReference[] typeArgs = new TypeReference[job.typeParams.length + 2]; for (int i = 0; i < job.typeParams.length; i++) { typeArgs[i] = new SingleTypeReference(job.typeParams[i].name, 0); } // 2. The return type for the build() method (named "C" in the abstract builder), which is the annotated class. // 3. The return type for all setter methods (named "B" in the abstract builder), which is this builder class. typeArgs[typeArgs.length - 2] = cloneSelfType(job.parentType, job.source); typeArgs[typeArgs.length - 1] = createTypeReferenceWithTypeParameters(job.parentType, builderImplClass, job.typeParams); builder.superclass = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, typeArgs, 0); } builder.createDefaultConstructor(false, true); builder.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null); return injectType(job.parentType, builder); } /** * Generates a constructor that has a builder as the only parameter. * The values from the builder are used to initialize the fields of new instances. * * @param callBuilderBasedSuperConstructor * If {@code true}, the constructor will explicitly call a super * constructor with the builder as argument. Requires * {@code builderClassAsParameter != null}. */ private void generateBuilderBasedConstructor(BuilderJob job, boolean callBuilderBasedSuperConstructor) { TypeDeclaration typeDeclaration = ((TypeDeclaration) job.parentType.get()); long p = job.getPos(); ConstructorDeclaration constructor = new ConstructorDeclaration(((CompilationUnitDeclaration) job.parentType.top().get()).compilationResult); constructor.modifiers = toEclipseModifier(AccessLevel.PROTECTED); constructor.selector = typeDeclaration.name; if (callBuilderBasedSuperConstructor) { constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.Super); constructor.constructorCall.arguments = new Expression[] {new SingleNameReference(BUILDER_VARIABLE_NAME, p)}; } else { constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper); } constructor.constructorCall.sourceStart = job.source.sourceStart; constructor.constructorCall.sourceEnd = job.source.sourceEnd; constructor.thrownExceptions = null; constructor.typeParameters = null; constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = job.source.sourceStart; constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = job.source.sourceEnd; TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND)}; TypeReference builderType = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), p); constructor.arguments = new Argument[] {new Argument(BUILDER_VARIABLE_NAME, p, builderType, Modifier.FINAL)}; List<Statement> statements = new ArrayList<Statement>(); for (BuilderFieldData fieldNode : job.builderFields) { FieldReference fieldInThis = new FieldReference(fieldNode.rawName, p); int s = (int) (p >> 32); int e = (int) p; fieldInThis.receiver = new ThisReference(s, e); Expression assignmentExpr; if (fieldNode.singularData != null && fieldNode.singularData.getSingularizer() != null) { fieldNode.singularData.getSingularizer().appendBuildCode(fieldNode.singularData, job.parentType, statements, fieldNode.builderFieldName, BUILDER_VARIABLE_NAME_STRING); assignmentExpr = new SingleNameReference(fieldNode.builderFieldName, p); } else { char[][] variableInBuilder = new char[][] {BUILDER_VARIABLE_NAME, fieldNode.builderFieldName}; long[] positions = new long[] {p, p}; assignmentExpr = new QualifiedNameReference(variableInBuilder, positions, s, e); } Statement assignment = new Assignment(fieldInThis, assignmentExpr, (int) p); // In case of @Builder.Default, set the value to the default if it was NOT set in the builder. if (fieldNode.nameOfSetFlag != null) { char[][] setVariableInBuilder = new char[][] {BUILDER_VARIABLE_NAME, fieldNode.nameOfSetFlag}; long[] positions = new long[] {p, p}; QualifiedNameReference setVariableInBuilderRef = new QualifiedNameReference(setVariableInBuilder, positions, s, e); MessageSend defaultMethodCall = new MessageSend(); defaultMethodCall.sourceStart = job.source.sourceStart; defaultMethodCall.sourceEnd = job.source.sourceEnd; defaultMethodCall.receiver = generateNameReference(job.parentType, 0L); defaultMethodCall.selector = fieldNode.nameOfDefaultProvider; defaultMethodCall.typeArguments = typeParameterNames(((TypeDeclaration) job.parentType.get()).typeParameters); Statement defaultAssignment = new Assignment(fieldInThis, defaultMethodCall, (int) p); IfStatement ifBlockForDefault = new IfStatement(setVariableInBuilderRef, assignment, defaultAssignment, s, e); statements.add(ifBlockForDefault); } else { statements.add(assignment); } if (hasNonNullAnnotations(fieldNode.originalFieldNode)) { Statement nullCheck = generateNullCheck((FieldDeclaration) fieldNode.originalFieldNode.get(), job.sourceNode, null); if (nullCheck != null) statements.add(nullCheck); } } constructor.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]); if (job.checkerFramework.generateSideEffectFree()) { constructor.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)}; } constructor.traverse(new SetGeneratedByVisitor(job.source), typeDeclaration.scope); injectMethod(job.parentType, constructor); } private MethodDeclaration generateBuilderMethod(SuperBuilderJob job) { int pS = job.source.sourceStart, pE = job.source.sourceEnd; long p = (long) pS << 32 | pE; MethodDeclaration out = job.createNewMethodDeclaration(); out.selector = job.builderMethodName.toCharArray(); out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic; out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; // Add type params if there are any. if (job.typeParams != null && job.typeParams.length > 0) out.typeParameters = copyTypeParams(job.typeParams, job.source); TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND) }; out.returnType = generateParameterizedTypeReference(job.parentType, job.builderAbstractClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), p); if (job.checkerFramework.generateUnique()) { int len = out.returnType.getTypeName().length; out.returnType.annotations = new Annotation[len][]; out.returnType.annotations[len - 1] = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__UNIQUE)}; } AllocationExpression invoke = new AllocationExpression(); invoke.type = namePlusTypeParamsToTypeReference(job.parentType, job.builderImplClassNameArr, false, job.typeParams, p); out.statements = new Statement[] {new ReturnStatement(invoke, pS, pE)}; if (job.checkerFramework.generateSideEffectFree()) { out.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)}; } createRelevantNonNullAnnotation(job.parentType, out); out.traverse(new SetGeneratedByVisitor(job.source), ((TypeDeclaration) job.parentType.get()).scope); return out; } /** * Generates a {@code toBuilder()} method in the annotated class that looks like this: * <pre> * public <i>Foobar</i>.<i>Foobar</i>Builder&lt;?, ?&gt; toBuilder() { * return new <i.Foobar</i>.<i>Foobar</i>BuilderImpl().$fillValuesFrom(this); * } * </pre> */ private MethodDeclaration generateToBuilderMethod(SuperBuilderJob job) { int pS = job.source.sourceStart, pE = job.source.sourceEnd; long p = (long) pS << 32 | pE; MethodDeclaration out = job.createNewMethodDeclaration(); out.selector = TO_BUILDER_METHOD_NAME; out.modifiers = ClassFileConstants.AccPublic; out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND) }; out.returnType = generateParameterizedTypeReference(job.parentType, job.builderAbstractClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), p); if (job.checkerFramework.generateUnique()) { int len = out.returnType.getTypeName().length; out.returnType.annotations = new Annotation[len][]; out.returnType.annotations[len - 1] = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__UNIQUE)}; } AllocationExpression newClass = new AllocationExpression(); newClass.type = namePlusTypeParamsToTypeReference(job.parentType, job.builderImplClassNameArr, false, job.typeParams, p); MessageSend invokeFillMethod = new MessageSend(); invokeFillMethod.receiver = newClass; invokeFillMethod.selector = FILL_VALUES_METHOD_NAME; invokeFillMethod.arguments = new Expression[] {new ThisReference(0, 0)}; out.statements = new Statement[] {new ReturnStatement(invokeFillMethod, pS, pE)}; if (job.checkerFramework.generateSideEffectFree()) { out.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)}; } createRelevantNonNullAnnotation(job.parentType, out); out.traverse(new SetGeneratedByVisitor(job.source), ((TypeDeclaration) job.parentType.get()).scope); return out; } /** * Generates a {@code $fillValuesFrom()} method in the abstract builder class. * It looks like: * <pre> * protected B $fillValuesFrom(final C instance) { * super.$fillValuesFrom(instance); * Foobar.FoobarBuilder.$fillValuesFromInstanceIntoBuilder(instance, this); * return self(); * } * </pre> */ private MethodDeclaration generateFillValuesMethod(SuperBuilderJob job, boolean inherited, String builderGenericName, String classGenericName) { MethodDeclaration out = job.createNewMethodDeclaration(); out.selector = FILL_VALUES_METHOD_NAME; out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.modifiers = ClassFileConstants.AccProtected; if (inherited) out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.parentType.get())}; out.returnType = new SingleTypeReference(builderGenericName.toCharArray(), 0); TypeReference builderType = new SingleTypeReference(classGenericName.toCharArray(), 0); out.arguments = new Argument[] {new Argument(INSTANCE_VARIABLE_NAME, 0, builderType, Modifier.FINAL)}; List<Statement> body = new ArrayList<Statement>(); if (inherited) { // Call super. MessageSend callToSuper = new MessageSend(); callToSuper.receiver = new SuperReference(0, 0); callToSuper.selector = FILL_VALUES_METHOD_NAME; callToSuper.arguments = new Expression[] {new SingleNameReference(INSTANCE_VARIABLE_NAME, 0)}; body.add(callToSuper); } // Call the builder implemention's helper method that actually fills the values from the instance. MessageSend callStaticFillValuesMethod = new MessageSend(); callStaticFillValuesMethod.receiver = generateNameReference(job.parentType, job.builderAbstractClassNameArr, 0); callStaticFillValuesMethod.selector = FILL_VALUES_STATIC_METHOD_NAME; callStaticFillValuesMethod.arguments = new Expression[] {new SingleNameReference(INSTANCE_VARIABLE_NAME, 0), new ThisReference(0, 0)}; body.add(callStaticFillValuesMethod); // Return self(). MessageSend returnCall = new MessageSend(); returnCall.receiver = ThisReference.implicitThis(); returnCall.selector = SELF_METHOD_NAME; body.add(new ReturnStatement(returnCall, 0, 0)); out.statements = body.isEmpty() ? null : body.toArray(new Statement[0]); return out; } /** * Generates a {@code $fillValuesFromInstanceIntoBuilder()} method in * the builder implementation class that copies all fields from the instance * to the builder. It looks like this: * * <pre> * protected B $fillValuesFromInstanceIntoBuilder(Foobar instance, FoobarBuilder&lt;?, ?&gt; b) { * b.field(instance.field); * } * </pre> * @param setterPrefix the prefix for setter methods */ private MethodDeclaration generateStaticFillValuesMethod(BuilderJob job, String setterPrefix) { MethodDeclaration out = job.createNewMethodDeclaration(); out.selector = FILL_VALUES_STATIC_METHOD_NAME; out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.modifiers = ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic; out.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0); TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND)}; TypeReference builderType = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), 0); Argument builderArgument = new Argument(BUILDER_VARIABLE_NAME, 0, builderType, Modifier.FINAL); TypeReference[] typerefs = null; if (job.typeParams.length > 0) { typerefs = new TypeReference[job.typeParams.length]; for (int i = 0; i < job.typeParams.length; i++) typerefs[i] = new SingleTypeReference(job.typeParams[i].name, 0); } long p = job.getPos(); TypeReference parentArgument = typerefs == null ? generateTypeReference(job.parentType, p) : generateParameterizedTypeReference(job.parentType, typerefs, p); out.arguments = new Argument[] {new Argument(INSTANCE_VARIABLE_NAME, 0, parentArgument, Modifier.FINAL), builderArgument}; // Add type params if there are any. if (job.typeParams.length > 0) out.typeParameters = copyTypeParams(job.typeParams, job.source); List<Statement> body = new ArrayList<Statement>(); // Call the builder's setter methods to fill the values from the instance. for (BuilderFieldData bfd : job.builderFields) { MessageSend exec = createSetterCallWithInstanceValue(bfd, job.parentType, job.source, setterPrefix); body.add(exec); } out.statements = body.isEmpty() ? null : body.toArray(new Statement[0]); out.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null); return out; } private MessageSend createSetterCallWithInstanceValue(BuilderFieldData bfd, EclipseNode type, ASTNode source, String setterPrefix) { char[] setterName = HandlerUtil.buildAccessorName(type, setterPrefix, String.valueOf(bfd.name)).toCharArray(); MessageSend ms = new MessageSend(); Expression[] tgt = new Expression[bfd.singularData == null ? 1 : 2]; if (bfd.obtainVia == null || !bfd.obtainVia.field().isEmpty()) { char[] fieldName = bfd.obtainVia == null ? bfd.rawName : bfd.obtainVia.field().toCharArray(); for (int i = 0; i < tgt.length; i++) { FieldReference fr = new FieldReference(fieldName, 0); fr.receiver = new SingleNameReference(INSTANCE_VARIABLE_NAME, 0); tgt[i] = fr; } } else { String obtainName = bfd.obtainVia.method(); boolean obtainIsStatic = bfd.obtainVia.isStatic(); for (int i = 0; i < tgt.length; i++) { MessageSend obtainExpr = new MessageSend(); obtainExpr.receiver = obtainIsStatic ? generateNameReference(type, 0) : new SingleNameReference(INSTANCE_VARIABLE_NAME, 0); obtainExpr.selector = obtainName.toCharArray(); if (obtainIsStatic) obtainExpr.arguments = new Expression[] {new SingleNameReference(INSTANCE_VARIABLE_NAME, 0)}; tgt[i] = obtainExpr; } } if (bfd.singularData == null) { ms.arguments = tgt; } else { Expression ifNull = new EqualExpression(tgt[0], new NullLiteral(0, 0), OperatorIds.EQUAL_EQUAL); MessageSend emptyCollection = bfd.singularData.getSingularizer().getEmptyExpression(bfd.singularData.getTargetFqn(), bfd.singularData, type, source); ms.arguments = new Expression[] {new ConditionalExpression(ifNull, emptyCollection, tgt[1])}; } ms.receiver = new SingleNameReference(BUILDER_VARIABLE_NAME, 0); ms.selector = setterName; return ms; } private MethodDeclaration generateAbstractSelfMethod(BuilderJob job, boolean override, String builderGenericName) { MethodDeclaration out = job.createNewMethodDeclaration(); out.selector = SELF_METHOD_NAME; out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.modifiers = ClassFileConstants.AccAbstract | ClassFileConstants.AccProtected | ExtraCompilerModifiers.AccSemicolonBody; Annotation overrideAnn = override ? makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.parentType.get()) : null; Annotation sefAnn = job.checkerFramework.generatePure() ? generateNamedAnnotation(job.parentType.get(), CheckerFrameworkVersion.NAME__PURE): null; if (overrideAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn}; else if (overrideAnn != null) out.annotations = new Annotation[] {overrideAnn}; else if (sefAnn != null) out.annotations = new Annotation[] {sefAnn}; out.returnType = new SingleTypeReference(builderGenericName.toCharArray(), 0); addCheckerFrameworkReturnsReceiver(out.returnType, job.parentType.get(), job.checkerFramework); return out; } private MethodDeclaration generateSelfMethod(BuilderJob job) { MethodDeclaration out = job.createNewMethodDeclaration(); out.selector = SELF_METHOD_NAME; out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.modifiers = ClassFileConstants.AccProtected; Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.builderType.get()); Annotation sefAnn = job.checkerFramework.generatePure() ? generateNamedAnnotation(job.builderType.get(), CheckerFrameworkVersion.NAME__PURE) : null; if (sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn}; else out.annotations = new Annotation[] {overrideAnn}; out.returnType = namePlusTypeParamsToTypeReference(job.builderType, job.typeParams, job.getPos()); addCheckerFrameworkReturnsReceiver(out.returnType, job.parentType.get(), job.checkerFramework); out.statements = new Statement[] {new ReturnStatement(new ThisReference(0, 0), 0, 0)}; return out; } private MethodDeclaration generateAbstractBuildMethod(BuilderJob job, boolean override, String classGenericName) { MethodDeclaration out = job.createNewMethodDeclaration(); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract | ExtraCompilerModifiers.AccSemicolonBody; out.selector = job.buildMethodName.toCharArray(); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.returnType = new SingleTypeReference(classGenericName.toCharArray(), 0); Annotation overrideAnn = override ? makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.source) : null; Annotation sefAnn = job.checkerFramework.generateSideEffectFree() ? generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null; if (overrideAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn}; else if (overrideAnn != null) out.annotations = new Annotation[] {overrideAnn}; else if (sefAnn != null) out.annotations = new Annotation[] {sefAnn}; out.receiver = HandleBuilder.generateBuildReceiver(job); out.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null); return out; } private MethodDeclaration generateBuildMethod(BuilderJob job, TypeReference returnType) { MethodDeclaration out = job.createNewMethodDeclaration(); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; List<Statement> statements = new ArrayList<Statement>(); out.modifiers = ClassFileConstants.AccPublic; out.selector = job.buildMethodName.toCharArray(); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.returnType = returnType; Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.source); Annotation sefAnn = job.checkerFramework.generateSideEffectFree() ? generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null; if (sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn}; else out.annotations = new Annotation[] {overrideAnn}; AllocationExpression allocationStatement = new AllocationExpression(); allocationStatement.type = copyType(out.returnType); // Use a constructor that only has this builder as parameter. allocationStatement.arguments = new Expression[] {new ThisReference(0, 0)}; statements.add(new ReturnStatement(allocationStatement, 0, 0)); out.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]); out.receiver = HandleBuilder.generateBuildReceiver(job); createRelevantNonNullAnnotation(job.builderType, out); out.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null); return out; } private MethodDeclaration generateCleanMethod(BuilderJob job) { List<Statement> statements = new ArrayList<Statement>(); for (BuilderFieldData bfd : job.builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, job.builderType, statements); } } FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0); thisUnclean.receiver = new ThisReference(0, 0); statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0)); MethodDeclaration decl = job.createNewMethodDeclaration(); //new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult); decl.selector = CLEAN_METHOD_NAME; decl.modifiers = ClassFileConstants.AccPrivate; decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0); decl.statements = statements.toArray(new Statement[0]); decl.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null); return decl; } private void generateBuilderFields(BuilderJob job) { List<EclipseNode> existing = new ArrayList<EclipseNode>(); for (EclipseNode child : job.builderType.down()) { if (child.getKind() == Kind.FIELD) existing.add(child); } for (BuilderFieldData bfd : job.builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, job.builderType)); } else { EclipseNode field = null, setFlag = null; for (EclipseNode exists : existing) { char[] n = ((FieldDeclaration) exists.get()).name; if (Arrays.equals(n, bfd.builderFieldName)) field = exists; if (bfd.nameOfSetFlag != null && Arrays.equals(n, bfd.nameOfSetFlag)) setFlag = exists; } if (field == null) { FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName.clone(), 0, 0); fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; fd.modifiers = ClassFileConstants.AccPrivate; fd.type = copyType(bfd.type); fd.traverse(new SetGeneratedByVisitor(job.source), (MethodScope) null); field = injectFieldAndMarkGenerated(job.builderType, fd); } if (setFlag == null && bfd.nameOfSetFlag != null) { FieldDeclaration fd = new FieldDeclaration(bfd.nameOfSetFlag, 0, 0); fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; fd.modifiers = ClassFileConstants.AccPrivate; fd.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0); fd.traverse(new SetGeneratedByVisitor(job.source), (MethodScope) null); injectFieldAndMarkGenerated(job.builderType, fd); } bfd.createdFields.add(field); } } } private void generateSetterMethodsForBuilder(BuilderJob job, BuilderFieldData bfd, final String builderGenericName, String setterPrefix) { boolean deprecate = isFieldDeprecated(bfd.originalFieldNode); TypeReferenceMaker returnTypeMaker = new TypeReferenceMaker() { @Override public TypeReference make() { return new SingleTypeReference(builderGenericName.toCharArray(), 0); } }; StatementMaker returnStatementMaker = new StatementMaker() { @Override public ReturnStatement make() { MessageSend returnCall = new MessageSend(); returnCall.receiver = ThisReference.implicitThis(); returnCall.selector = SELF_METHOD_NAME; return new ReturnStatement(returnCall, 0, 0); } }; if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) { generateSimpleSetterMethodForBuilder(job, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), bfd.annotations, bfd.originalFieldNode, setterPrefix); } else { bfd.singularData.getSingularizer().generateMethods(job.checkerFramework, bfd.singularData, deprecate, job.builderType, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC); } } private void generateSimpleSetterMethodForBuilder(BuilderJob job, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, TypeReference returnType, Statement returnStatement, Annotation[] annosOnParam, EclipseNode originalFieldNode, String setterPrefix) { TypeDeclaration td = (TypeDeclaration) job.builderType.get(); AbstractMethodDeclaration[] existing = td.methods; if (existing == null) existing = EMPTY_METHODS; int len = existing.length; String setterName = HandlerUtil.buildAccessorName(job.sourceNode, setterPrefix, new String(paramName)); for (int i = 0; i < len; i++) { if (!(existing[i] instanceof MethodDeclaration)) continue; char[] existingName = existing[i].selector; if (Arrays.equals(setterName.toCharArray(), existingName) && !isTolerate(fieldNode, existing[i])) return; } List<Annotation> methodAnnsList = Arrays.asList(EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode, true)); addCheckerFrameworkReturnsReceiver(returnType, job.source, job.checkerFramework); MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, returnType, returnStatement, ClassFileConstants.AccPublic, job.sourceNode, methodAnnsList, annosOnParam != null ? Arrays.asList(copyAnnotations(job.source, annosOnParam)) : Collections.<Annotation>emptyList()); if (job.sourceNode.up().getKind() == Kind.METHOD) { copyJavadocFromParam(originalFieldNode.up(), setter, td, paramName.toString()); } else { copyJavadoc(originalFieldNode, setter, td, CopyJavadoc.SETTER, true); } injectMethod(job.builderType, setter); } private void addObtainVia(BuilderFieldData bfd, EclipseNode node) { for (EclipseNode child : node.down()) { if (!annotationTypeMatches(ObtainVia.class, child)) continue; AnnotationValues<ObtainVia> ann = createAnnotation(ObtainVia.class, child); bfd.obtainVia = ann.getInstance(); bfd.obtainViaNode = child; return; } } /** * Returns the explicitly requested singular annotation on this node (field * or parameter), or null if there's no {@code @Singular} annotation on it. * * @param node The node (field or method param) to inspect for its name and potential {@code @Singular} annotation. * @param setterPrefix the prefix for setter methods */ private SingularData getSingularData(EclipseNode node, ASTNode source, String setterPrefix) { for (EclipseNode child : node.down()) { if (!annotationTypeMatches(Singular.class, child)) continue; char[] pluralName = node.getKind() == Kind.FIELD ? removePrefixFromField(node) : ((AbstractVariableDeclaration) node.get()).name; AnnotationValues<Singular> ann = createAnnotation(Singular.class, child); Singular singularInstance = ann.getInstance(); String explicitSingular = singularInstance.value(); if (explicitSingular.isEmpty()) { if (Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.SINGULAR_AUTO))) { node.addError("The singular must be specified explicitly (e.g. @Singular(\"task\")) because auto singularization is disabled."); explicitSingular = new String(pluralName); } else { explicitSingular = autoSingularize(new String(pluralName)); if (explicitSingular == null) { node.addError("Can't singularize this name; please specify the singular explicitly (i.e. @Singular(\"sheep\"))"); explicitSingular = new String(pluralName); } } } char[] singularName = explicitSingular.toCharArray(); TypeReference type = ((AbstractVariableDeclaration) node.get()).type; TypeReference[] typeArgs = null; String typeName; if (type instanceof ParameterizedSingleTypeReference) { typeArgs = ((ParameterizedSingleTypeReference) type).typeArguments; typeName = new String(((ParameterizedSingleTypeReference) type).token); } else if (type instanceof ParameterizedQualifiedTypeReference) { TypeReference[][] tr = ((ParameterizedQualifiedTypeReference) type).typeArguments; if (tr != null) typeArgs = tr[tr.length - 1]; char[][] tokens = ((ParameterizedQualifiedTypeReference) type).tokens; StringBuilder sb = new StringBuilder(); for (int i = 0; i < tokens.length; i++) { if (i > 0) sb.append("."); sb.append(tokens[i]); } typeName = sb.toString(); } else { typeName = type.toString(); } String targetFqn = EclipseSingularsRecipes.get().toQualified(typeName); EclipseSingularizer singularizer = EclipseSingularsRecipes.get().getSingularizer(targetFqn); if (singularizer == null) { node.addError("Lombok does not know how to create the singular-form builder methods for type '" + typeName + "'; they won't be generated."); return null; } return new SingularData(child, singularName, pluralName, typeArgs == null ? Collections.<TypeReference>emptyList() : Arrays.asList(typeArgs), targetFqn, singularizer, source, singularInstance.ignoreNullCollections(), setterPrefix.toCharArray()); } return null; } private java.util.Set<String> gatherUsedTypeNames(TypeParameter[] typeParams, TypeDeclaration td) { java.util.HashSet<String> usedNames = new HashSet<String>(); // 1. Add type parameter names. for (TypeParameter typeParam : typeParams) usedNames.add(typeParam.toString()); // 2. Add class name. usedNames.add(String.valueOf(td.name)); // 3. Add used type names. if (td.fields != null) { for (FieldDeclaration field : td.fields) { if (field instanceof Initializer) continue; addFirstToken(usedNames, field.type); } } // 4. Add extends and implements clauses. addFirstToken(usedNames, td.superclass); if (td.superInterfaces != null) { for (TypeReference typeReference : td.superInterfaces) { addFirstToken(usedNames, typeReference); } } return usedNames; } private void addFirstToken(java.util.Set<String> usedNames, TypeReference type) { if (type == null) return; // Add the first token, because only that can collide. char[][] typeName = type.getTypeName(); if (typeName != null && typeName.length >= 1) usedNames.add(String.valueOf(typeName[0])); } private String generateNonclashingNameFor(String classGenericName, java.util.Set<String> typeParamStrings) { if (!typeParamStrings.contains(classGenericName)) return classGenericName; int counter = 2; while (typeParamStrings.contains(classGenericName + counter)) counter++; return classGenericName + counter; } private TypeReference[] appendBuilderTypeReferences(TypeParameter[] typeParams, String classGenericName, String builderGenericName) { TypeReference[] typeReferencesToAppend = new TypeReference[2]; typeReferencesToAppend[typeReferencesToAppend.length - 2] = new SingleTypeReference(classGenericName.toCharArray(), 0); typeReferencesToAppend[typeReferencesToAppend.length - 1] = new SingleTypeReference(builderGenericName.toCharArray(), 0); return mergeToTypeReferences(typeParams, typeReferencesToAppend); } private TypeReference[] getTypeParametersFrom(TypeReference typeRef) { TypeReference[][] typeArgss = null; if (typeRef instanceof ParameterizedQualifiedTypeReference) { typeArgss = ((ParameterizedQualifiedTypeReference) typeRef).typeArguments; } else if (typeRef instanceof ParameterizedSingleTypeReference) { typeArgss = new TypeReference[][] {((ParameterizedSingleTypeReference) typeRef).typeArguments}; } TypeReference[] typeArgs = new TypeReference[0]; if (typeArgss != null && typeArgss.length > 0) { typeArgs = typeArgss[typeArgss.length - 1]; } return typeArgs; } private static TypeReference createTypeReferenceWithTypeParameters(EclipseNode parent, String referenceName, TypeParameter[] typeParams) { if (typeParams.length > 0) { TypeReference[] typerefs = new TypeReference[typeParams.length]; for (int i = 0; i < typeParams.length; i++) { typerefs[i] = new SingleTypeReference(typeParams[i].name, 0); } return generateParameterizedTypeReference(parent, referenceName.toCharArray(), false, typerefs, 0); } else { return generateTypeReference(parent, referenceName.toCharArray(), false, 0); } } private TypeReference[] mergeToTypeReferences(TypeParameter[] typeParams, TypeReference[] typeReferencesToAppend) { TypeReference[] typerefs = new TypeReference[typeParams.length + typeReferencesToAppend.length]; for (int i = 0; i < typeParams.length; i++) { typerefs[i] = new SingleTypeReference(typeParams[i].name, 0); } for (int i = 0; i < typeReferencesToAppend.length; i++) { typerefs[typeParams.length + i] = typeReferencesToAppend[i]; } return typerefs; } private TypeReference[] mergeTypeReferences(TypeReference[] refs1, TypeReference[] refs2) { TypeReference[] result = new TypeReference[refs1.length + refs2.length]; for (int i = 0; i < refs1.length; i++) result[i] = refs1[i]; for (int i = 0; i < refs2.length; i++) result[refs1.length + i] = refs2[i]; return result; } private TypeReference[] typeParameterNames(TypeParameter[] typeParameters) { if (typeParameters == null) return null; TypeReference[] trs = new TypeReference[typeParameters.length]; for (int i = 0; i < trs.length; i++) { trs[i] = new SingleTypeReference(typeParameters[i].name, 0); } return trs; } private EclipseNode findInnerClass(EclipseNode parent, String name) { char[] c = name.toCharArray(); for (EclipseNode child : parent.down()) { if (child.getKind() != Kind.TYPE) continue; TypeDeclaration td = (TypeDeclaration) child.get(); if (Arrays.equals(td.name, c)) return child; } return null; } private static final char[] prefixWith(char[] prefix, char[] name) { char[] out = new char[prefix.length + name.length]; System.arraycopy(prefix, 0, out, 0, prefix.length); System.arraycopy(name, 0, out, prefix.length, name.length); return out; } private boolean constructorExists(EclipseNode type, String builderClassName) { if (type != null && type.get() instanceof TypeDeclaration) { TypeDeclaration typeDecl = (TypeDeclaration)type.get(); if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) { if (def instanceof ConstructorDeclaration) { if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue; if (!def.isConstructor()) continue; if (isTolerate(type, def)) continue; if (def.arguments == null || def.arguments.length != 1) continue; // Cannot use typeMatches() here, because the parameter could be fully-qualified, partially-qualified, or not qualified. // A string-compare of the last part should work. If it's a false-positive, users could still @Tolerate it. char[] typeName = def.arguments[0].type.getLastToken(); if (builderClassName.equals(String.valueOf(typeName))) return true; } } } return false; } }
0
gem/oq-engine
1,251
openquake/qa_tests_data/classical_damage/case_6a/fragility_model.xml
<?xml version="1.0" encoding="utf-8"?> <nrml xmlns="http://openquake.org/xmlns/nrml/0.5" > <fragilityModel assetCategory="building" id="fm_13_converted_from_NRML_04" lossCategory="structural" > <description> Fragility Functions for Case 6a </description> <limitStates> slight moderate extreme complete </limitStates> <fragilityFunction format="discrete" id="Wood" shape="logncdf" > <imls imt="PGA" noDamageLimit="5.0000000E-02" > 0.2 0.4 0.6 0.8 1.0 1.2 1.4 </imls> <poes ls="slight" > 0.771 0.95 0.989 0.997 0.999 1.0 1.0 </poes> <poes ls="moderate" > 0.5 0.861 0.957 0.985 0.994 0.997 0.999 </poes> <poes ls="extreme" > 0.231 0.636 0.837 0.924 0.962 0.981 0.989 </poes> <poes ls="complete" > 0.097 0.414 0.661 0.806 0.887 0.933 0.959 </poes> </fragilityFunction> </fragilityModel> </nrml>
0
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
-