Changeset - 265b2706e075
[Not reviewed]
default
0 38 0
Branko Majic (branko) - 11 years ago 2013-10-11 20:01:48
branko@majic.rs
CONNT-22: Added licensing information to Python files. Added licensing information to documentation files.
38 files changed with 756 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conntrackt/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/admin.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.contrib import admin
 
from django.core.urlresolvers import resolve
 

	
 
# Application imports.
 
from .models import Project, Location, Entity, Interface, Communication
 

	
 

	
 
class InterfaceInline(admin.StackedInline):
 
    """
 
    This class implements the inline admin view of the Interface instances. This
 
    is used when adding the entities (since it's easier to specify interface for
conntrackt/forms.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.forms import ModelForm
 

	
 
# Application imports.
 
from .models import Project, Location, Entity, Interface, Communication
 

	
 

	
 
class WidgetCSSClassFormMixin(object):
 
    """
 
    Helper form mixin that can be used for applying additional custom CSS
 
    classes to form field widgets.
 

	
conntrackt/iptables.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Python imports.
 
from operator import attrgetter
 

	
 

	
 
class Rule(object):
 
    """
 
    Class representing a single iptables rule. The representation does not
 
    include the chain to which it is applied, or how it is applied (append vs
 
    insert).
 

	
 
    The instances of this class can be used for easily outputting a single rule.
 
    """
conntrackt/migrations/0001_initial.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding model 'Project'
 
        db.create_table('conntrackt_project', (
conntrackt/migrations/0002_auto__add_unique_communication_source_destination_protocol_port.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding unique constraint on 'Communication', fields ['source', 'destination', 'protocol', 'port']
 
        db.create_unique(u'conntrackt_communication', ['source_id', 'destination_id', 'protocol', 'port'])
conntrackt/migrations/0003_auto__add_unique_entity_project_name__add_unique_location_name__add_un.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding unique constraint on 'Entity', fields ['project', 'name']
 
        db.create_unique(u'conntrackt_entity', ['project_id', 'name'])
conntrackt/migrations/0004_auto__add_unique_interface_netmask_address_entity.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# -*- coding: utf-8 -*-
 
import datetime
 
from south.db import db
 
from south.v2 import SchemaMigration
 
from django.db import models
 

	
 

	
 
class Migration(SchemaMigration):
 

	
 
    def forwards(self, orm):
 
        # Adding unique constraint on 'Interface', fields ['netmask', 'address', 'entity']
 
        db.create_unique(u'conntrackt_interface', ['netmask', 'address', 'entity_id'])
conntrackt/migrations/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/models.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.core.exceptions import ValidationError
 
from django.core.urlresolvers import reverse
 
from django.db import models
 

	
 

	
 
class Project(models.Model):
 
    """
 
    Implements a model with information about a project. A project has some
 
    basic settings, and mainly serves the purpose of grouping entities for
 
    easier handling and administration.
 

	
conntrackt/templatetags/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/templatetags/conntrackt_tags.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django import template
 
from django.core import urlresolvers
 

	
 

	
 
# Get an instance of Django's template library.
 
register = template.Library()
 

	
 

	
 
@register.simple_tag(takes_context=False)
 
def html_link(text, view, *args, **kwargs):
 
    """
conntrackt/tests/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
conntrackt/tests/factories.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Third-party application imports.
 
import factory
 

	
 
# Application imports.
 
from conntrackt.models import Project, Location, Entity, Interface, Communication
 

	
 

	
 
class ProjectFactory(factory.django.DjangoModelFactory):
 
    """
 
    Factory for producing projects where name is set to "Test Project N", and N
 
    is an increasing sequence. Description is based on name.
 
    """
conntrackt/tests/forms.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports
 
from django import forms
 

	
 
# Application imports.
 
from conntrackt.forms import WidgetCSSClassFormMixin, PlaceholderFormMixin
 

	
 

	
 
class FormWithWidgetCSSClassFormMixin(WidgetCSSClassFormMixin, forms.Form):
 
    """
 
    Helper form for testing the WidgetCSSClassFormMixin.
 
    """
 

	
conntrackt/tests/helpers.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Python standard library imports.
 
from types import FunctionType
 

	
 
# Python third-party library imports.
 
import mock
 

	
 
# Django imports.
 
from django.core.exceptions import PermissionDenied
 
from django.contrib.auth.models import User, Permission
 
from django.test import RequestFactory
 

	
 

	
conntrackt/tests/test_forms.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.test import TestCase
 

	
 
# Python third-party library imports.
 
import mock
 

	
 
# Application imports.
 
from conntrackt.forms import WidgetCSSClassFormMixin, PlaceholderFormMixin
 
from conntrackt.forms import EntityForm, InterfaceForm, CommunicationForm
 

	
 
# Test imports.
 
from .forms import FormWithWidgetCSSClassFormMixin, FormWithPlaceholderFormMixin
conntrackt/tests/test_iptables.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.test import TestCase
 

	
 
# Application imports.
 
from conntrackt import iptables
 

	
 

	
 
class RuleTest(TestCase):
 
    def test_output_case(self):
 
        """
 
        Test that protocol name is lower-cased during rule generation.
 
        """
conntrackt/tests/test_models.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.core.exceptions import ValidationError
 
from django.db import IntegrityError
 
from django.test import TestCase
 

	
 
# Application imports.
 
from conntrackt.models import Project, Location, Entity, Interface, Communication
 

	
 
# Test imports.
 
from .factories import ProjectFactory, LocationFactory
 
from .factories import ServerEntityFactory, ServerInterfaceFactory
 
from .factories import SubnetEntityFactory, SubnetInterfaceFactory
conntrackt/tests/test_utils.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.test import TestCase
 

	
 
# Third-party Python library imports.
 
import palette
 
import pydot
 

	
 
# Application imports.
 
from conntrackt.models import Entity, Project, Communication
 
from conntrackt import utils
 
from .factories import setup_test_data
 

	
conntrackt/tests/test_views.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Standard library imports.
 
from StringIO import StringIO
 
from zipfile import ZipFile, ZIP_DEFLATED
 

	
 
# Python third-party library imports.
 
import mock
 

	
 
# Django imports.
 
from django.core.urlresolvers import reverse
 
from django.http import Http404
 
from django.test import RequestFactory
 
from django.test import TestCase
conntrackt/tests/views.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Application imports.
 
from conntrackt.views import RedirectToNextMixin
 

	
 

	
 
class StaticSuccessUrlFakeMixin(object):
 
    """
 
    Helper view for testing the RedirectToNextMixinView mixin.
 
    """
 

	
 
    def get_success_url(self):
 
        return self.success_url
 

	
conntrackt/urls.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports.
 
from django.conf.urls import patterns, url
 
from django.contrib.auth.views import login, logout
 

	
 
# Application imports.
 
from .views import IndexView, EntityView, entity_iptables, project_iptables, project_diagram
 
from .views import ProjectView, ProjectCreateView, ProjectUpdateView, ProjectDeleteView
 
from .views import LocationCreateView, LocationUpdateView, LocationDeleteView
 
from .views import EntityCreateView, EntityUpdateView, EntityDeleteView
 
from .views import InterfaceCreateView, InterfaceUpdateView, InterfaceDeleteView
 
from .views import CommunicationCreateView, CommunicationUpdateView, CommunicationDeleteView
 

	
conntrackt/utils.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Standard library imports.
 
import re
 
import itertools
 

	
 
# Third-party Python library imports.
 
import palette
 
import pydot
 

	
 
# Django imports.
 
from django.template import Context, loader
 

	
 
# Application imports.
conntrackt/views.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Standard library imports.
 
from StringIO import StringIO
 
from zipfile import ZipFile, ZIP_DEFLATED
 

	
 
# Django imports.
 
from django.contrib.auth.decorators import permission_required
 
from django.contrib import messages
 
from django.core.urlresolvers import reverse, reverse_lazy
 
from django.http import HttpResponse
 
from django.shortcuts import render_to_response, get_object_or_404
 
from django.views.generic import TemplateView, DetailView, CreateView, UpdateView, DeleteView
 

	
docs/about.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
About Django Conntrackt
 
=======================
 

	
 
Django Conntrackt is a simple application intended to provide system
 
administrators and integrators that deploy servers at client's premises to
 
easily keep track of required networ communications between different servers,
 
routers, client workstations, and even whole networks/sub-networks.
 

	
 

	
 
Why was this application created?
 
---------------------------------
 

	
docs/conf.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django Conntrackt documentation build configuration file, created by
 
# sphinx-quickstart on Sun Apr 14 21:47:09 2013.
 
#
 
# This file is execfile()d with the current directory set to its containing dir.
 
#
 
# Note that not all possible configuration values are present in this
 
# autogenerated file.
 
#
 
# All configuration values have a default; values that are commented out
 
# serve to show the default.
 

	
 
import sys
docs/index.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Django Conntrackt documentation
 
===============================
 

	
 
Django Conntrackt is a simple application intended to provide system
 
administrators and integrators that deploy servers at client's premises to
 
easily keep track of required networ communications between different servers,
 
routers, client workstations, and even whole networks/sub-networks.
 

	
 

	
 
Support
 
-------
 

	
docs/installation.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Installation
 
============
 

	
 
Django Conntrackt can be installed through one of the following methods:
 

	
 
* Using *pip*, which is the recommended way for production
 
  websites.
 

	
 

	
 
Using pip
 
---------
 

	
docs/quickstart.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Quick-start guide
 
=================
 

	
 
This chapter provides quick-start instructions in order to allow you to quickly deploy and test Django Conntrackt application.
 

	
 

	
 
Debian/Ubuntu
 
-------------
 

	
 
Install the *pip* utility::
 

	
 
  sudo apt-get install pip
docs/releasenotes.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
Release Notes
 
=============
 

	
 
0.1
 
---
 

	
 
Initial relase of Django Conntrackt. Contains full support for:
 

	
 
* Managing application data.
 
* Generation of iptables rules.
 
* Generation of communication diagram.
 
* Full user documentation.
docs/usage.rst
Show inline comments
 
.. Copyright (C) 2013 Branko Majic
 

	
 
   This file is part of Django Conntrackt documentation.
 

	
 
   This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
 
   Unported License. To view a copy of this license, visit
 
   http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
 
   Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 

	
 
.. _usage:
 

	
 
Usage
 
=====
 

	
 
Django Conntrackt provides a very simple interface for reading and editing the
 
information about network connections across projects, as well as for obtaining
 
*iptables* rules.
 

	
 
Key concepts
 
------------
 

	
projtest/manage.py
Show inline comments
 
#!/usr/bin/env python
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
import os
 
import sys
 

	
 
if __name__ == "__main__":
 
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projtest.settings")
 

	
 
    from django.core.management import execute_from_command_line
 

	
 
    execute_from_command_line(sys.argv)
projtest/projtest/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
projtest/projtest/settings.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django settings for projtest project.
 
DEBUG = True
 
TEMPLATE_DEBUG = DEBUG
 

	
 
ADMINS = (
 
    ('Branko Majic', 'branko@majic.rs'),
 
)
 

	
 
MANAGERS = ADMINS
 

	
 
DATABASES = {
 
    'default': {
projtest/projtest/urls.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
# Django imports
 
from django.conf.urls import patterns, include, url
 
from django.contrib import admin
 
from django.http import HttpResponseRedirect
 

	
 

	
 
# Auto-discover admin interface.
 
admin.autodiscover()
 

	
 

	
 
urlpatterns = patterns(
 
    '',
projtest/projtest/wsgi.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
"""
 
WSGI config for projtest project.
 

	
 
This module contains the WSGI application used by Django's development server
 
and any production WSGI deployments. It should expose a module-level variable
 
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
 
this application via the ``WSGI_APPLICATION`` setting.
 

	
 
Usually you will have the standard Django WSGI application here, but it also
 
might make sense to replace the whole Django WSGI application with a custom one
 
that later delegates to the Django one. For example, you could introduce WSGI
 
middleware here, or combine a Django application with an application of another
setup.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
#
 
# Copyright (C) 2013 Branko Majic
 
#
 
# This file is part of Django Conntrackt.
 
#
 
# Django Conntrackt is free software: you can redistribute it and/or modify it
 
# under the terms of the GNU General Public License as published by the Free
 
# Software Foundation, either version 3 of the License, or (at your option) any
 
# later version.
 
#
 
# Django Conntrackt is distributed in the hope that it will be useful, but
 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
# details.
 
#
 
# You should have received a copy of the GNU General Public License along with
 
# Django Conntrackt.  If not, see <http://www.gnu.org/licenses/>.
 
#
 

	
 

	
 
import os
 
from setuptools import setup, find_packages
 
from pip.req import parse_requirements
 

	
 
README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
 
INSTALL_REQUIREMENTS = [str(r.req) for r in parse_requirements("requirements/production.txt")]
 
TEST_REQUIREMENTS = [str(r.req) for r in parse_requirements("requirements/test.txt")]
 

	
 
# allow setup.py to be run from any path
 
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
 

	
 
setup(
0 comments (0 inline, 0 general)