<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2987/">https://reviewboard.asterisk.org/r/2987/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On November 7th, 2013, 9:58 p.m. UTC, <b>David Lee</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2987/diff/2/?file=48011#file48011line1839" style="color: black; font-weight: bold; text-decoration: underline;">branches/12/main/rtp_engine.c</a>
<span style="font-weight: normal;">
(Diff revision 2)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static struct ast_json *rtcp_report_to_json(struct stasis_message *msg)</pre></td>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static struct ast_json *rtcp_report_to_json(struct stasis_message *msg,</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">1838</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="hl"><span class="tb"> </span></span><span class="n"><span class="hl">json_payload</span></span><span class="hl"> </span><span class="o"><span class="hl">=</span></span> <span class="n">ast_json_pack</span><span class="p">(</span><span class="s">"{s: O, s: O, s: O}"</span><span class="p">,</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1838</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="hl"><span class="tb"> </span></span><span class="k"><span class="hl">return</span></span> <span class="n">ast_json_pack</span><span class="p">(</span><span class="s">"{s: O, s: O, s: O}"</span><span class="p">,</span></pre></td>
</tr>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">1839</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="s">"channel"</span><span class="p">,</span> <span class="n">payload</span><span class="o">-></span><span class="n">snapshot</span> <span class="o">?</span> <span class="n">ast_channel_snapshot_to_json</span><span class="p">(</span><span class="n">payload</span><span class="o">-></span><span class="n">snapshot</span><span class="p">)</span> <span class="o">:</span> <span class="n">ast_json_null</span><span class="p">(),</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1839</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="s">"channel"</span><span class="p">,</span> <span class="n">payload</span><span class="o">-></span><span class="n">snapshot</span> <span class="o">?</span> <span class="n">ast_channel_snapshot_to_json</span><span class="p">(</span><span class="n">payload</span><span class="o">-></span><span class="n">snapshot</span><span class="p"><span class="hl">,</span></span><span class="hl"> </span><span class="n"><span class="hl">sanitize</span></span><span class="p">)</span> <span class="o">:</span> <span class="n">ast_json_null</span><span class="p">(),</span></pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">1840</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="s">"rtcp_report"</span><span class="p">,</span> <span class="n">json_rtcp_report</span><span class="p">,</span></pre></td>
<th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1840</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="s">"rtcp_report"</span><span class="p">,</span> <span class="n">json_rtcp_report</span><span class="p">,</span></pre></td>
</tr>
<tr>
<th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">1841</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="s">"blob"</span><span class="p">,</span> <span class="n">payload</span><span class="o">-></span><span class="n">blob</span><span class="p">);</span></pre></td>
<th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1841</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="s">"blob"</span><span class="p">,</span> <span class="n">payload</span><span class="o">-></span><span class="n">blob</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Just a guess, but I think you'd want to drop the RTCP report completely if the associated channel was filtered out by the sanitizer.</pre>
</blockquote>
<p>On November 8th, 2013, 3:13 a.m. UTC, <b>opticron</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This will pass a NULL into the ast_json_pack causing it to fail and return NULL if the channel snapshot is sanitized away.</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Yeah, I don't like relying on that behavior.
(1) It relies on ast_json_pack to properly handle a failure from its underlying function calls. That's brittle.
(2) It's *really* hard to tell that the behavior you described is what will occur here. That increases the maintenance burden of this code.
I agree with David: check the sanitizer result first and explicitly return NULL if you aren't supposed to return any data; otherwise, continue with the message formatting.</pre>
<br />
<p>- Matt</p>
<br />
<p>On November 11th, 2013, 3:12 p.m. UTC, opticron wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By opticron.</div>
<p style="color: grey;"><i>Updated Nov. 11, 2013, 3:12 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-22744">ASTERISK-22744</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This change prevents channels used as implementation details from leaking out to ARI. It does this by preventing creation of JSON blobs of channel snapshots created from those channels and sanitizing JSON blobs of bridge snapshots as they are created. This introduces a framework for excluding information from output targeted at Stasis applications on a consumer-by-consumer basis using channel sanitization callbacks which could be extended to bridges or endpoints if necessary.
This results in NULL inputs to ast_json_pack calls which generate unhelpful error messages, so that has been dealt with as well.
This also corrects a bug I noticed while investigating the issue where BridgeCreated events would not be created.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Manual testing with bridges and channels.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>branches/12/res/stasis/app.c <span style="color: grey">(402347)</span></li>
<li>branches/12/res/res_stasis.c <span style="color: grey">(402347)</span></li>
<li>branches/12/res/ari/resource_endpoints.c <span style="color: grey">(402347)</span></li>
<li>branches/12/res/ari/resource_channels.c <span style="color: grey">(402347)</span></li>
<li>branches/12/res/ari/resource_bridges.c <span style="color: grey">(402347)</span></li>
<li>branches/12/main/stasis_message.c <span style="color: grey">(402347)</span></li>
<li>branches/12/main/stasis_endpoints.c <span style="color: grey">(402347)</span></li>
<li>branches/12/main/stasis_channels.c <span style="color: grey">(402347)</span></li>
<li>branches/12/main/stasis_bridges.c <span style="color: grey">(402347)</span></li>
<li>branches/12/main/rtp_engine.c <span style="color: grey">(402347)</span></li>
<li>branches/12/main/json.c <span style="color: grey">(402347)</span></li>
<li>branches/12/include/asterisk/stasis_endpoints.h <span style="color: grey">(402347)</span></li>
<li>branches/12/include/asterisk/stasis_channels.h <span style="color: grey">(402347)</span></li>
<li>branches/12/include/asterisk/stasis_bridges.h <span style="color: grey">(402347)</span></li>
<li>branches/12/include/asterisk/stasis_app.h <span style="color: grey">(402347)</span></li>
<li>branches/12/include/asterisk/stasis.h <span style="color: grey">(402347)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2987/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>