Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Arreglo bug
Browse files Browse the repository at this point in the history
  • Loading branch information
videlanicolas committed Jun 14, 2017
1 parent a23b723 commit cf350ae
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 34 deletions.
38 changes: 27 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,57 @@
FROM ubuntu:xenial

#Install dependencies
RUN apt-get update && apt-get install -y apache2 libapache2-mod-wsgi openssl python-lxml && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update &&\
apt-get install -y apache2 libapache2-mod-wsgi openssl python-lxml && apt-get clean &&\
rm -rf /var/lib/apt/lists/*

#Version information and maintainer
LABEL version:"1.2.2" maintainer:"Nicolas Videla"

#Expose only SSL
EXPOSE 443/tcp

#Create directories
RUN mkdir -p /var/www/assimilator/flask /var/www/assimilator/app /etc/apache2/ssl

#Create log file
RUN touch /var/log/assimilator.log

#Date
ARG CACHE_DATE=2016-01-01

#Copy configuration
COPY assimilator_vhost.conf /etc/apache2/sites-available/assimilator_vhost.conf
COPY run.py /var/www/assimilator/run.py
COPY assimilator.wsgi /var/www/assimilator/assimilator.wsgi
#COPY assimilator.conf /etc/assimilator/assimilator.conf
COPY assimilator.conf /etc/assimilator/assimilator.conf

#Create firewalls.json file
#RUN touch /etc/assimilator/firewalls.json
RUN touch /etc/assimilator/firewalls.json

#Create apikey storage
#RUN touch /etc/assimilator/api.key
RUN touch /etc/assimilator/api.key
RUN touch /var/www/assimilator/__init__.py

#Install assimilator
COPY app/ /var/www/assimilator/app/
COPY flask/ /var/www/assimilator/flask/

#Copy private RSA key
COPY assimilator.key /etc/apache2/ssl/assimilator.key
COPY assimilator.crt /etc/apache2/ssl/assimilator.crt

#Assigning permissions
RUN chown -R www-data:www-data /var/www/assimilator/
RUN chown www-data:www-data /etc/apache2/ssl/assimilator.key /etc/apache2/ssl/assimilator.crt /etc/apache2/sites-available/assimilator_vhost.conf /var/log/assimilator.log
#RUN chmod 600 /etc/assimilator/*
RUN chmod 600 /etc/assimilator/*

#Enable mods
RUN a2enmod ssl wsgi

#Enable API
RUN a2ensite assimilator_vhost
#Expose only SSL
EXPOSE 443/tcp
#Version information and maintainer
LABEL version:"1.0" maintainer:"Nicolas Videla"

#Run apache
COPY entrypoint /usr/bin/entrypoint
ENTRYPOINT entrypoint
#ENTRYPOINT /usr/sbin/apache2ctl -D FOREGROUND
ENTRYPOINT entrypoint
19 changes: 2 additions & 17 deletions app/modules/PaloAlto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,21 +1816,6 @@ def get(self):
else:
soup = BeautifulSoup(response.text,'xml')
logging = list()
if not soup.profiles:
log_static = {
'arias' : 'Log_fwd_meli',
'uruguay' : 'Log_fwd_meli',
'sanluis' : 'Log_fwd_meli',
'mexico' : 'LF_Threats_Traffic',
'brasil' : 'Log_fwd_meli',
'usa' : 'LF_syslog01-ar',
'colombia' : 'LF_Traffic_Threats',
'cordoba' : 'LF_Threats_Traffic',
'chile' : 'LF_Threats_Only'
}
if self.firewall in log_static:
logging.append(log_static[self.firewall])
else:
for a in soup.response.result.profiles.find_all('entry'):
logging.append(a['name'])
for a in soup.response.result.profiles.find_all('entry'):
logging.append(a['name'])
return {'log-settings' : logging }
6 changes: 3 additions & 3 deletions app/modules/apikeymgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def delete(self,id):
logger.error("Cannot JSON parse API key file.")
return {}, 204
try:
if id not in apikeys:
if str(id) not in apikeys:
logger.warning("ID not found.")
return {'error' : 'ID not found.'}, 404
else:
Expand Down Expand Up @@ -120,8 +120,8 @@ def post(self):
if apikeys:
aux = list()
for k,v in apikeys.iteritems():
aux.append(int(k))
id = str(aux[-1] + 2)
aux.append(int(k))
id = str(sorted(aux)[-1] + 1)
else:
id = "1"
key = {id : {"token" : list(), "comment" : request.json['comment'] if 'comment' in request.json else None ,"key" : ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(100))}}
Expand Down
Binary file modified docs/build/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/.doctrees/user/api.doctree
Binary file not shown.
23 changes: 23 additions & 0 deletions docs/build/_sources/user/api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Gets the full configuration of the Firewall, in it's native format. In many case
200 OK

.. block-code: json
{
"config" : " ... "
}
Expand All @@ -38,6 +39,7 @@ Rules
Get all rules in the selected Firewall. This can be filtered with URL arguments.

*Example (PaloAlto)*

::
GET /api/argentina/rules
Expand All @@ -49,6 +51,7 @@ Get all rules in the selected Firewall. This can be filtered with URL arguments.
200 OK

.. block-code: json
{
"rules" : [
{
Expand Down Expand Up @@ -103,6 +106,7 @@ Get all rules in the selected Firewall. This can be filtered with URL arguments.
}
*Example with arguments (PaloAlto)*

::
GET /api/argentina/rules?from=dmz&to=untrust
Expand All @@ -114,6 +118,7 @@ Get all rules in the selected Firewall. This can be filtered with URL arguments.
200 OK

.. block-code: json
{
"rules" : [
{
Expand Down Expand Up @@ -223,3 +228,21 @@ To add a rule one simply changes the method to POST and sends one of these JSON
"action": "allow"
}

Objects
-------

**/api/<firewall>/objects/<address|address-group|service|service-group>**

Firewall objects identify hosts and ports in the rules, basically there are four type of objects:

* Address: Hosts identified by an IP, IP range, subnet or FQDN.
* Service: A combination of protocol and source/destination port.
* Address Group: A group of Address objects.
* Service Group: A group of service objects.




Routes
------

2 changes: 2 additions & 0 deletions docs/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ <h1>Welcome to Assimilator’s documentation!<a class="headerlink" href="#welcom
<li class="toctree-l1"><a class="reference internal" href="user/api.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="user/api.html#config">Config</a></li>
<li class="toctree-l2"><a class="reference internal" href="user/api.html#rules">Rules</a></li>
<li class="toctree-l2"><a class="reference internal" href="user/api.html#objects">Objects</a></li>
<li class="toctree-l2"><a class="reference internal" href="user/api.html#routes">Routes</a></li>
</ul>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/build/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions docs/build/user/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
<li class="toctree-l1 current"><a class="current reference internal" href="#">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#config">Config</a></li>
<li class="toctree-l2"><a class="reference internal" href="#rules">Rules</a></li>
<li class="toctree-l2"><a class="reference internal" href="#objects">Objects</a></li>
<li class="toctree-l2"><a class="reference internal" href="#routes">Routes</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -256,6 +258,22 @@ <h2>Rules<a class="headerlink" href="#rules" title="Permalink to this headline">
</pre></div>
</div>
</div>
<div class="section" id="objects">
<h2>Objects<a class="headerlink" href="#objects" title="Permalink to this headline"></a></h2>
<p><strong>/api/&lt;firewall&gt;/objects/&lt;address|address-group|service|service-group&gt;</strong></p>
<p>Firewall objects identify hosts and ports in the rules, basically there are four type of objects:</p>
<blockquote>
<div><ul class="simple">
<li>Address: Hosts identified by an IP, IP range, subnet or FQDN.</li>
<li>Service: A combination of protocol and source/destination port.</li>
<li>Address Group: A group of Address objects.</li>
<li>Service Group: A group of service objects.</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="routes">
<h2>Routes<a class="headerlink" href="#routes" title="Permalink to this headline"></a></h2>
</div>
</div>


Expand Down
Loading

0 comments on commit cf350ae

Please sign in to comment.