示例#1
0
class MessageTypeArea(Gtk.Box):

    NEW_MODIFY = 0
    DEPENDENCY = 1
    TEMPLATE = 2
    EQUIVALENCY = 3
    GENERATION = 4

    def __init__(self, the_packet_area, iserver):
        Gtk.Box.__init__(self, spacing=10, orientation=Gtk.Orientation.VERTICAL)
        self.set_homogeneous(False)

        # components of the MessageTypeArea
        self.msgtype_view = MessageType(iserver, the_packet_area)
        self.dependency_view = Dependency(iserver, the_packet_area)
        self.page_num = 0

        title = Gtk.Label()
        title.set_markup("<u><b><big> Message Type Area </big></b></u>")
        title.set_xalign(0.05)
        self.pack_start(title, True, True, 0)

        notebook = Gtk.Notebook()
        notebook.connect("switch_page", self.update_page)
        pages = [('New/Modify', self.msgtype_view),
                 ('Dependency', self.dependency_view),
                 ('Template', Template()),
                 ('Equivalency', Equivalency()),
                 ('Generation', Generation())]
        self.append_pages(notebook, pages)
        self.pack_start(notebook, True, True, 0)

    def append_pages(self, notebook, pages):
        for page in pages:
            name, content = page
            notebook.append_page(content, Gtk.Label(name))

    def insert_pairs(self, pairs):
        if self.page_num == self.NEW_MODIFY:
            self.msgtype_view.insert_fields(pairs)
        if self.page_num == self.DEPENDENCY:
            self.dependency_view.insert_fields(pairs)

    def remove_pairs(self, pairs):
        if self.page_num == self.NEW_MODIFY:
            self.msgtype_view.remove_fields(pairs)
        if self.page_num == self.DEPENDENCY:
            self.dependency_view.remove_fields(pairs)

    def update_page(self, notebook, page, page_num):
        self.page_num = page_num
        if page_num == self.NEW_MODIFY or page_num == self.DEPENDENCY:
            page.update_msgtype_cbox()
    def __init__(self, sourceFieldName, targetFieldName):
        Dependency.__init__(self, sourceFieldName, targetFieldName)

        rootField = PDML.filterField(sourceFieldName)
        childField = PDML.filterField(targetFieldName)

        # satisfies SRS#93
        if rootField.getSize() < childField.getSize():
            raise Exception("Field size not large enough for field")

        else:
            return self
    def __init__(self, packetName, fieldName):
        Dependency.__init__(self, PacketName, fieldName)

        rootPacket = PDML.filterField(PacketName)
        childField = PDML.filterField(fieldName)

        # satisfies SRS#97
        if rootPacket.getSize() < childField.getSize():
            raise Exception("Packet size not large enough for field")

        else:
            return self
示例#4
0
def load_dependencies(sqlite_db_path):
    print(sqlite_db_path)
    conn = sqlite3.connect(Config.NOW_DB_PATH)
    cursor = conn.cursor()
    query = (
        "select D.type as 'DEPENDENCY_TYPE', "
        "EV_INFLU.trial_id, EV_INFLU.id, EV_INFLU.checkpoint, EV_INFLU.code_component_id, EV_INFLU.activation_id, "
        "EV_INFLU.repr, EV_INFLU.member_container_activation_id, EV_INFLU.member_container_id, CC_INFLU.name, CC_INFLU.type, "
        "EV_DEPEND.trial_id, EV_DEPEND.id, EV_DEPEND.checkpoint, EV_DEPEND.code_component_id, EV_DEPEND.activation_id, "
        "EV_DEPEND.repr, EV_DEPEND.member_container_activation_id, EV_DEPEND.member_container_id, CC_DEPEND.name, CC_DEPEND.type "
        "from dependency D "
        "join evaluation EV_DEPEND on D.dependent_id = EV_DEPEND.id "
        "join evaluation EV_INFLU on D.dependency_id = EV_INFLU.id "
        "join code_component CC_DEPEND on EV_DEPEND.code_component_id = CC_DEPEND.id "
        "join code_component CC_INFLU on EV_INFLU.code_component_id = CC_INFLU.id "
    )
    dependencies = []
    for tupl in cursor.execute(query, []):
        typeof = tupl[0]
        target = Evaluation(tupl[1], tupl[2], tupl[3], tupl[4], tupl[5],
                            tupl[6], tupl[7], tupl[8], tupl[9], tupl[10])
        source = Evaluation(tupl[11], tupl[12], tupl[13], tupl[14], tupl[15],
                            tupl[16], tupl[17], tupl[18], tupl[19], tupl[20])
        dependencies.append(Dependency(source, target, typeof))
    conn.close()
    return dependencies
    def delete_special_tag(self, tag_type, tag_descriptor, combobox):
        """
        * Parameter: tag_type (str)
        * Parameter: tag_descriptor (str)
        * Delete object (Dependency or Software Category Object)
        * depending on tag_type
        * Pop tag_descriptor key in tag_dict
        """

        tag_dict = self.software_categories if tag_type == 'sc' else self.dependencies
        feature = self.inventory[self]

        if tag_type == 'sc':
            SoftwareCategory.delete_category(feature, tag_descriptor)
        else:
            Dependency.delete_dependency(feature, tag_descriptor)

        tag_dict.pop(tag_descriptor)
        current_index = combobox.currentIndex()
        combobox.removeItem(current_index)
示例#6
0
def main(l, params):

    act = Activity(l)
    
    l = preProcessLog(l, act.a)

    print("")
    print("############## ACTIVITIES SET ##############")
    act = Activity(l)
    print(act.a)

    print("")
    print("############## LOG LIST ##############")
    log = Log(l)
    print(log.l)

    print("")
    print("############## FREQUENCY TABLE ##############")
    freq = FrequencyDirectlyFollows(log.l, act.a)
    print(freq.ft)

    print("")
    print("############## DEPENDENCY TABLE ##############")
    depen = Dependency(freq.ft, act.a)
    print(depen.dt)

    print("")
    print("############## CNET A_I AND A_O ##############")
    cnet = CNet(act.a, log.l, freq.ft, depen.dt, params)
    print(cnet.a_i)
    print(cnet.a_o)

    print("")
    print("############## CNET DEPENDENCY OUT ##############")
    print(cnet.depRelOut)

    print("")
    print("############## CNET DEPENDENCY IN ##############")
    print(cnet.depRelIn)

    print("")
    print("############## CNET OUTPUT BINDINGS ##############")
    print(cnet.outBind)
 
    print("")
    print("############## CNET INPUT BINDINGS ##############")
    print(cnet.inBind)

    print("")
    print("############## CNET IS VALID SEQUENCE ##############")
    print(cnet.isValidSequence(['a','b','b','e'], 4))
示例#7
0
    def __init__(self, the_packet_area, iserver):
        Gtk.Box.__init__(self, spacing=10, orientation=Gtk.Orientation.VERTICAL)
        self.set_homogeneous(False)

        # components of the MessageTypeArea
        self.msgtype_view = MessageType(iserver, the_packet_area)
        self.dependency_view = Dependency(iserver, the_packet_area)
        self.page_num = 0

        title = Gtk.Label()
        title.set_markup("<u><b><big> Message Type Area </big></b></u>")
        title.set_xalign(0.05)
        self.pack_start(title, True, True, 0)

        notebook = Gtk.Notebook()
        notebook.connect("switch_page", self.update_page)
        pages = [('New/Modify', self.msgtype_view),
                 ('Dependency', self.dependency_view),
                 ('Template', Template()),
                 ('Equivalency', Equivalency()),
                 ('Generation', Generation())]
        self.append_pages(notebook, pages)
        self.pack_start(notebook, True, True, 0)
示例#8
0
    def getFull(self):
        if (not self.fieldsExists or not self.fileExists):
            raise StopIteration

        if (self.hash):
            return self.hash

        self.hash = {}
        self.client_name = ''

        try:
            while True:
                client_name, client_version, client_timestamp, client_previous_timestamp, dependency_name, dependency_type, dependency_resolved_version, dependency_resolved_version_change = self.next(
                )

                self.client_name = client_name
                # name, version, type
                dependency = Dependency(dependency_name,
                                        dependency_resolved_version,
                                        dependency_type,
                                        dependency_resolved_version_change)

                try:
                    # release.addDependency
                    release = self.hash[client_version]  # get the release

                    if release.client_previous_timestamp.__eq__(
                            ''):  # if client_previous_timestamp is null
                        release.client_previous_timestamp = client_previous_timestamp

                    release.addDependency(dependency)
                except KeyError:  # if is first release in csv file
                    release = Release(
                        client_version, client_timestamp,
                        client_previous_timestamp)  # create new release
                    release.addDependency(dependency)  # add dependency
                    self.hash[client_version] = release  # insert in hash

        except StopIteration:
            return self.hash
def load_dependencies(sqlite_db_path):
    print(sqlite_db_path)
    conn = sqlite3.connect(sqlite_db_path)
    cursor = conn.cursor()
    query = ("select D.type as 'DEPENDENCY_TYPE', "
            "CC_INFLU.trial_id, CC_INFLU.id, CC_INFLU.name, CC_INFLU.type, CC_INFLU.mode, "
            "CC_INFLU.first_char_line, CC_INFLU.first_char_column, CC_INFLU.last_char_line, CC_INFLU.last_char_column, CC_INFLU.container_id, "
            "CC_DEPEND.trial_id, CC_DEPEND.id, CC_DEPEND.name, CC_DEPEND.type, CC_DEPEND.mode, "
            "CC_DEPEND.first_char_line, CC_DEPEND.first_char_column, CC_DEPEND.last_char_line, CC_DEPEND.last_char_column, CC_DEPEND.container_id "
            "from dependency D "
            "join evaluation EV_DEPEND on D.dependent_id = EV_DEPEND.id "
            "join evaluation EV_INFLU on D.dependency_id = EV_INFLU.id "
            "join code_component CC_DEPEND on EV_DEPEND.code_component_id = CC_DEPEND.id "
            "join code_component CC_INFLU on EV_INFLU.code_component_id = CC_INFLU.id " )
    dependencies = []
    for tupl in cursor.execute(query,[]):
        typeof = tupl[0]
        target = CodeComponent(tupl[1],tupl[2],tupl[3],tupl[4],tupl[5],tupl[6],tupl[7],tupl[8],tupl[9],tupl[10])
        source = CodeComponent(tupl[11],tupl[12],tupl[13],tupl[14],tupl[15],tupl[16],tupl[17],tupl[18],tupl[19],tupl[20])
        dependencies.append(Dependency(source,target,typeof))
    conn.close()
    return dependencies
示例#10
0
 def prepare_new_dependency(self):
     d = Dependency(-1, self.existing_environment_1, self.existing_role_1,
                    self.existing_role_2, self.existing_type,
                    self.existing_dependency, 'This is a test dependency')
     return d
示例#11
0
def build(objtId, p):
    if (p.__class__.__name__ == 'AttackerParameters'):
        return Attacker(objtId, p.name(), p.description(), p.image(), p.tags(),
                        p.environmentProperties())
    if (p.__class__.__name__ == 'PersonaParameters'):
        return Persona(objtId, p.name(), p.activities(), p.attitudes(),
                       p.aptitudes(), p.motivations(),
                       p.skills(), p.intrinsic(), p.contextual(), p.image(),
                       p.assumption(), p.type(), p.tags(),
                       p.environmentProperties(), p.codes())
    if (p.__class__.__name__ == 'AssetParameters'):
        return Asset(objtId, p.name(), p.shortCode(), p.description(),
                     p.significance(), p.type(), p.critical(),
                     p.criticalRationale(), p.tags(), p.interfaces(),
                     p.environmentProperties())
    if (p.__class__.__name__ == 'TemplateAssetParameters'):
        return TemplateAsset(objtId, p.name(), p.shortCode(), p.description(),
                             p.significance(), p.type(), p.surfaceType(),
                             p.accessRight(), p.properties(), p.rationale(),
                             p.tags(), p.interfaces())
    if (p.__class__.__name__ == 'TemplateRequirementParameters'):
        return TemplateRequirement(objtId, p.name(), p.asset(), p.type(),
                                   p.description(), p.rationale(),
                                   p.fitCriterion())
    if (p.__class__.__name__ == 'TemplateGoalParameters'):
        return TemplateGoal(objtId, p.name(), p.definition(), p.rationale(),
                            p.concerns(), p.responsibilities())
    if (p.__class__.__name__ == 'SecurityPatternParameters'):
        return SecurityPattern(objtId, p.name(), p.context(), p.problem(),
                               p.solution(), p.requirements(),
                               p.associations())
    if (p.__class__.__name__ == 'ComponentParameters'):
        return Component(objtId, p.name(), p.description(), p.interfaces(),
                         p.structure(), p.requirements(), p.goals(),
                         p.associations())
    if (p.__class__.__name__ == 'ComponentViewParameters'):
        return ComponentView(objtId, p.name(), p.synopsis(), p.components(),
                             p.connectors(), p.attackSurfaceMetric())
    if (p.__class__.__name__ == 'ValueTypeParameters'):
        return ValueType(objtId, p.name(), p.description(), p.type(),
                         p.score(), p.rationale())
    if (p.__class__.__name__ == 'ClassAssociationParameters'):
        return ClassAssociation(objtId, p.environment(), p.headAsset(),
                                p.headDimension(), p.headNavigation(),
                                p.headType(), p.headMultiplicity(),
                                p.headRole(), p.tailRole(),
                                p.tailMultiplicity(), p.tailType(),
                                p.tailNavigation(), p.tailDimension(),
                                p.tailAsset(), p.rationale())
    if (p.__class__.__name__ == 'GoalAssociationParameters'):
        return GoalAssociation(objtId, p.environment(), p.goal(),
                               p.goalDimension(), p.type(), p.subGoal(),
                               p.subGoalDimension(), p.alternative(),
                               p.rationale())
    if (p.__class__.__name__ == 'DependencyParameters'):
        return Dependency(objtId, p.environment(), p.depender(), p.dependee(),
                          p.dependencyType(), p.dependency(), p.rationale())
    if (p.__class__.__name__ == 'GoalParameters'):
        return Goal(objtId, p.name(), p.originator(), p.tags(),
                    p.environmentProperties())
    if (p.__class__.__name__ == 'ObstacleParameters'):
        return Obstacle(objtId, p.name(), p.originator(), p.tags(),
                        p.environmentProperties())
    if (p.__class__.__name__ == 'DomainPropertyParameters'):
        return DomainProperty(objtId, p.name(), p.description(), p.type(),
                              p.originator(), p.tags())
    if (p.__class__.__name__ == 'ThreatParameters'):
        return Threat(objtId, p.name(), p.type(), p.method(), p.tags(),
                      p.environmentProperties())
    if (p.__class__.__name__ == 'VulnerabilityParameters'):
        return Vulnerability(objtId, p.name(), p.description(), p.type(),
                             p.tags(), p.environmentProperties())
    if (p.__class__.__name__ == 'RiskParameters'):
        return Risk(objtId, p.name(), p.threat(), p.vulnerability(), p.tags(),
                    p.misuseCase())
    if (p.__class__.__name__ == 'ResponseParameters'):
        return Response(objtId, p.name(), p.risk(), p.tags(),
                        p.environmentProperties(), p.responseType())
    if (p.__class__.__name__ == 'CountermeasureParameters'):
        return Countermeasure(objtId, p.name(), p.description(), p.type(),
                              p.tags(), p.environmentProperties())
    if (p.__class__.__name__ == 'TaskParameters'):
        return Task(objtId, p.name(), p.shortCode(), p.objective(),
                    p.assumption(), p.author(), p.tags(),
                    p.environmentProperties())
    if (p.__class__.__name__ == 'UseCaseParameters'):
        return UseCase(objtId, p.name(), p.author(), p.code(), p.actors(),
                       p.description(), p.tags(), p.environmentProperties())
    if (p.__class__.__name__ == 'MisuseCaseParameters'):
        return MisuseCase(objtId, p.name(), p.environmentProperties(),
                          p.risk())
    if (p.__class__.__name__ == 'DotTraceParameters'):
        return DotTrace(p.fromObject(), p.fromName(), p.toObject(), p.toName())
    if (p.__class__.__name__ == 'EnvironmentParameters'):
        return Environment(objtId, p.name(), p.shortCode(), p.description(),
                           p.environments(), p.duplicateProperty(),
                           p.overridingEnvironment(), p.tensions())
    if (p.__class__.__name__ == 'RoleParameters'):
        return Role(objtId, p.name(), p.type(), p.shortCode(), p.description(),
                    p.environmentProperties())
    if (p.__class__.__name__ == 'ResponsibilityParameters'):
        return Responsibility(objtId, p.name())
    if (p.__class__.__name__ == 'ExternalDocumentParameters'):
        return ExternalDocument(objtId, p.name(), p.version(), p.date(),
                                p.authors(), p.description())
    if (p.__class__.__name__ == 'InternalDocumentParameters'):
        return InternalDocument(objtId, p.name(), p.description(), p.content(),
                                p.codes(), p.memos())
    if (p.__class__.__name__ == 'CodeParameters'):
        return Code(objtId, p.name(), p.type(), p.description(),
                    p.inclusionCriteria(), p.example())
    if (p.__class__.__name__ == 'MemoParameters'):
        return Memo(objtId, p.name(), p.description())
    if (p.__class__.__name__ == 'DocumentReferenceParameters'):
        return DocumentReference(objtId, p.name(), p.document(),
                                 p.contributor(), p.description())
    if (p.__class__.__name__ == 'ConceptReferenceParameters'):
        return ConceptReference(objtId, p.name(), p.dimension(),
                                p.objectName(), p.description())
    if (p.__class__.__name__ == 'PersonaCharacteristicParameters'):
        return PersonaCharacteristic(objtId, p.persona(), p.qualifier(),
                                     p.behaviouralVariable(),
                                     p.characteristic(), p.grounds(),
                                     p.warrant(), p.backing(), p.rebuttal())
    if (p.__class__.__name__ == 'TaskCharacteristicParameters'):
        return TaskCharacteristic(objtId, p.task(), p.qualifier(),
                                  p.characteristic(), p.grounds(), p.warrant(),
                                  p.backing(), p.rebuttal())
    if (p.__class__.__name__ == 'ImpliedProcessParameters'):
        return ImpliedProcess(objtId, p.name(), p.description(), p.persona(),
                              p.network(), p.specification(), p.channels())
    if (p.__class__.__name__ == 'LocationsParameters'):
        return Locations(objtId, p.name(), p.diagram(), p.locations(),
                         p.links())
    else:
        raise UnknownParameterClass(str(objtId))