Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex may potential match all traffic #2645

Merged
merged 6 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import akka.actor.UntypedActorFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.restcomm.connect.commons.common.http.CustomHttpClientBuilder;
import org.restcomm.connect.interpreter.NumberSelectorService;
import scala.concurrent.ExecutionContext;

/**
Expand Down Expand Up @@ -353,6 +354,9 @@ public void servletInitialized(SipServletContextEvent event) {
IdentityContext identityContext = new IdentityContext(xml);
context.setAttribute(IdentityContext.class.getName(), identityContext);

//init NumberSelectorService
context.setAttribute(NumberSelectorService.class.getName(), new NumberSelectorService(storage.getIncomingPhoneNumbersDao()));

// Create the media gateway.

//Initialize Monitoring Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter;

/**
* This class was designed to be used with exclusivity by {@link RvdProjectsMigrator}, once that
Expand Down Expand Up @@ -318,7 +319,8 @@ public int updateIncomingPhoneNumbers(String applicationSid, String projectName)
try {

if (dids == null) {
dids = didsDao.getAllIncomingPhoneNumbers();
IncomingPhoneNumberFilter.Builder filterBuilder = IncomingPhoneNumberFilter.Builder.builder();
dids = didsDao.getIncomingPhoneNumbersByFilter(filterBuilder.build());
}
} catch (Exception e) {
throw new RvdProjectsMigrationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,36 @@
</select>

<select id="getIncomingPhoneNumbersRegex" resultType="hashmap">
SELECT * FROM restcomm_incoming_phone_numbers WHERE phone_number like '%*%' or phone_number like '%#%' or phone_number like '%^%' or phone_number like '%|%' or phone_number like '%.%' or phone_number like '%$%' or phone_number like '%\%' or phone_number like '%[%' or phone_number like '%]%' ;
SELECT * FROM restcomm_incoming_phone_numbers WHERE ( phone_number like '%*%' or phone_number like '%#%' or phone_number like '%^%' or phone_number like '%|%' or phone_number like '%.%' or phone_number like '%$%' or phone_number like '%\%' or phone_number like '%[%' or phone_number like '%]%' )
<if test="friendlyName != null">
AND friendly_name=#{friendlyName}
</if>
<if test="orgSid != null">
AND organization_sid = #{orgSid}
</if>
<if test="accountSid != null">
AND account_sid = #{accountSid}
</if>
<if test="pureSIP != null">
AND pure_sip = #{pureSIP}
</if>
<choose>
<when test="sortBy == 'phone_number'">
order by phone_number ${sortDirection}
</when>
<when test="sortBy == 'friendly_name'">
order by friendly_name ${sortDirection}
</when>
<otherwise>
order by phone_number ${sortDirection}
</otherwise>
</choose>
<if test="limit != null">
LIMIT #{limit} OFFSET #{offset}
</if>
;
</select>
<!--
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="string" resultType="hashmap">
SELECT * FROM restcomm_incoming_phone_numbers WHERE account_sid=#{accountSid}
<if test="friendlyName != null">
AND friendly_name=#{friendlyName}
</if>
<if test="phoneNumber != null">
AND phone_number like #{phoneNumber}
</if>
</select>
-->


<!-- along with the DID it returns the application friendly name where it exists -->
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="hashmap">
Expand All @@ -66,30 +83,95 @@
AND n.friendly_name=#{friendlyName}
</if>
<if test="phoneNumber != null">
AND n.phone_number like #{phoneNumber}
AND n.phone_number = #{phoneNumber}
</if>
<if test="orgSid != null">
AND n.organization_sid = #{orgSid}
</if>
<if test="accountSid != null">
AND n.account_sid = #{accountSid}
</if>
<if test="pureSIP != null">
AND n.pure_sip = #{pureSIP}
</if>
<choose>
<when test="sortBy == 'phone_number'">
order by n.phone_number ${sortDirection}
</when>
<when test="sortBy == 'friendly_name'">
order by n.friendly_name ${sortDirection}
</when>
<otherwise>
order by n.phone_number ${sortDirection}
</otherwise>
</choose>
LIMIT #{limit} OFFSET #{offset}
<when test="sortBy == 'phone_number'">
order by n.phone_number ${sortDirection}
</when>
<when test="sortBy == 'friendly_name'">
order by n.friendly_name ${sortDirection}
</when>
<otherwise>
order by n.phone_number ${sortDirection}
</otherwise>
</choose>
<if test="limit != null">
LIMIT #{limit} OFFSET #{offset}
</if>
</select>
<select id="getTotalIncomingPhoneNumbersByUsingFilters" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="int">
SELECT COUNT(*) FROM restcomm_incoming_phone_numbers WHERE account_sid=#{accountSid}

<if test="friendlyName != null">
AND friendly_name=#{friendlyName}

<select id="searchNumbersWithWildcardMode" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="hashmap">
SELECT
n.*,
a_voice.friendly_name voice_application_name,
a_sms.friendly_name sms_application_name,
a_ussd.friendly_name ussd_application_name,
a_refer.friendly_name refer_application_name
FROM restcomm_incoming_phone_numbers n
LEFT OUTER JOIN restcomm_applications a_voice ON n.voice_application_sid = a_voice.sid
LEFT OUTER JOIN restcomm_applications a_sms ON n.sms_application_sid = a_sms.sid
LEFT OUTER JOIN restcomm_applications a_ussd ON n.ussd_application_sid = a_ussd.sid
LEFT OUTER JOIN restcomm_applications a_refer ON n.refer_application_sid = a_refer.sid
WHERE n.account_sid=#{accountSid}
<if test="friendlyName != null">
AND n.friendly_name like #{friendlyName}
</if>
<if test="phoneNumber != null">
AND phone_number like #{phoneNumber}
AND n.phone_number like #{phoneNumber}
</if>
<if test="orgSid != null">
AND n.organization_sid = #{orgSid}
</if>
<if test="accountSid != null">
AND n.account_sid = #{accountSid}
</if>
<if test="pureSIP != null">
AND n.pure_sip = #{pureSIP}
</if>
<choose>
<when test="sortBy == 'phone_number'">
order by n.phone_number ${sortDirection}
</when>
<when test="sortBy == 'friendly_name'">
order by n.friendly_name ${sortDirection}
</when>
<otherwise>
order by n.phone_number ${sortDirection}
</otherwise>
</choose>
<if test="limit != null">
LIMIT #{limit} OFFSET #{offset}
</if>
</select>

<select id="getTotalIncomingPhoneNumbersByUsingFilters" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="int">
SELECT COUNT(*) FROM restcomm_incoming_phone_numbers WHERE account_sid=#{accountSid}

<if test="friendlyName != null">
AND friendly_name like #{friendlyName}
</if>
<if test="phoneNumber != null">
AND phone_number like #{phoneNumber}
</if>
<if test="orgSid != null">
AND organization_sid = #{orgSid}
</if>
<if test="accountSid != null">
AND account_sid = #{accountSid}
</if>
<if test="pureSIP != null">
AND pure_sip = #{pureSIP}
</if>

</select>

Expand Down
Loading