コード例 #1
0
def addprofile():

    existResult = db_session.query(Rules_Profile).filter_by(
        name=request.form['name']).first()

    try:
        _pattern = None
        #같은 이름의 룰이 존재한다면 추가 대신 수정한다.
        if (existResult == None):
            _pattern = Rules_Profile()
        else:
            _pattern = existResult

        _pattern.group_code = request.form.get('group_code')
        _pattern.name = request.form['name']
        _pattern.description = request.form['description']
        _pattern.pattern_ui = request.form['pattern_ui']
        _pattern.pattern_query = GetLinkDnaListQueryForProfile(
            _pattern.pattern_ui)
        _pattern.pattern_operation = GetProfileOperation(
            _pattern.pattern_ui, request.form['name'],
            request.form.get('group_code'))
        db_session.add(_pattern)
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #2
0
ファイル: manage.py プロジェクト: MiscCoding/gsp_web
def editTypeA(seq):

    try:
        existResult = db_session.query(Link_Element_TypeA).filter(
            and_(
                Link_Element_TypeA.id != seq,
                Link_Element_TypeA.dst_columns_name ==
                request.form['dst_column'],
                Link_Element_TypeA == request.form['type'])).all()
        if (existResult != None and existResult.__len__() > 0):
            raise InvalidUsage('중복된 요소가 존재합니다.', status_code=501)

        src_dataElement = Data_Element.query.filter_by(data_source = request.form['type']).\
            filter_by(column_name = request.form['src_column']).first()

        _pattern = Link_Element_TypeA.query.filter_by(id=seq).first()
        _pattern.src_type = request.form['type']
        _pattern.src_columns_name = request.form['src_column']
        _pattern.dst_columns_name = request.form['dst_column']
        _pattern.description = request.form['desc']
        _pattern.dst_data_type = src_dataElement.getLinkDataType()[0]
        _pattern.dst_data_size = src_dataElement.getLinkDataType()[1]
        _pattern.use_yn = request.form['use_yn']
        _pattern.del_yn = 'N'

        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #3
0
def editCompany_IP_Element_url(seq):
    _pattern = db_session.query(Integrated_Company_IP_Management).filter_by(
        seq=seq).first()
    try:

        _pattern.Head_Quarter = request.form['Head_Quarter'].strip()
        _pattern.Center_Name = request.form['Center_Name'].strip()
        _pattern.Team_Name = request.form['Team_Name'].strip()
        _pattern.IP_Address = request.form['IP_Address'].strip()
        _pattern.Host_Name = request.form['Host_Name'].strip()
        _pattern.Device_Description = request.form['Device_Description'].strip(
        )

        # _pattern.Customer_Category = request.form['Customer_Category'].strip()
        # _pattern.Customer_Name = request.form['Customer_Name'].strip()
        # _pattern.IP_Address = request.form['IP_Address'].strip()
        # _pattern.Branch = request.form['Branch'].strip()
        # _pattern.IP_Address = request.form['IP_Address'].strip()
        _pattern.Description = request.form['Description'].strip()
        # _pattern.Password = request.form['Password'].strip()
        # _pattern.description = request.form['desc']
        # _pattern.mod_dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
コード例 #4
0
def deletewhiteip_url(seq):
    _pattern = db_session.query(Integrated_IPS_Management).filter_by(
        seq=seq).first()
    if _pattern is not None:
        db_session.delete(_pattern)
        db_session.commit()
    return ""
コード例 #5
0
def delete_Company_IP_Management_element_url(seq):
    _pattern = db_session.query(Integrated_Company_IP_Management).filter_by(
        seq=seq).first()
    if _pattern is not None:
        db_session.delete(_pattern)
        db_session.commit()
    return ""
コード例 #6
0
def delete_Customer_Category_url(seq):
    _pattern = db_session.query(Integrated_Customer_Category).filter_by(
        seq=seq).first()
    if _pattern is not None:
        db_session.delete(_pattern)
        db_session.commit()
    return ""
コード例 #7
0
def save_crawlingList():
    try:
        depth = CommonCode.query.filter(
            and_(CommonCode.GroupCode == "cl",
                 CommonCode.Code == "001")).first()
        depth.EXT1 = request.form.get('depth')
        extension = CommonCode.query.filter(
            and_(CommonCode.GroupCode == "cl",
                 CommonCode.Code == "002")).first()
        extension.EXT1 = request.form.get('extionsions')
        max_size = CommonCode.query.filter(
            and_(CommonCode.GroupCode == "cl",
                 CommonCode.Code == "003")).first()
        max_size.EXT1 = request.form.get('maxsize')
        timeout = CommonCode.query.filter(
            and_(CommonCode.GroupCode == "cl",
                 CommonCode.Code == "004")).first()
        timeout.EXT1 = request.form.get('timeout')
        removalPeriod = CommonCode.query.filter(
            and_(CommonCode.GroupCode == "cl",
                 CommonCode.Code == "005")).first()
        removalPeriod.EXT1 = request.form.get('removalPeriod')
        db_session.commit()

    except Exception as e:
        db_session.rollback()
        #print e.message
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #8
0
def addcrawllist():

    # try:
    #     _pattern = Rules_Crawl()
    #     _pattern.uri =request.form['pattern']
    #     _pattern.depth = int(request.form['depth'])
    #     _pattern.desc = request.form['desc']
    #     _pattern.register_path = request.form['source']
    #     Rules_Crawl.insertData(_pattern)
    #
    # except Exception as e:
    #     raise InvalidUsage('DB 저장 오류', status_code = 501)
    try:
        _pattern = Manual_Crawling_Info()
        # _pattern.type = request.form['type']

        _pattern.depth = request.form['depth'].strip()
        _pattern.url = request.form['url'].strip()
        # _pattern.mask = request.form['mask'].strip()
        _pattern.comment = request.form['comment']
        db_session.add(_pattern)
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #9
0
ファイル: manage.py プロジェクト: MiscCoding/gsp_web
def addTypeA():
    existResult = db_session.query(Link_Element_TypeA).filter_by(src_type = request.form['type'])\
        .filter_by(dst_columns_name=request.form['dst_column']).first()
    if (existResult != None):
        raise InvalidUsage('중복된 요소가 존재합니다.', status_code=501)

    src_dataElement = Data_Element.query.filter_by(data_source=request.form['type']). \
        filter_by(column_name=request.form['src_column']).first()

    try:
        _pattern = Link_Element_TypeA()
        _pattern.src_type = request.form['type']
        _pattern.src_columns_name = request.form['src_column']
        _pattern.dst_columns_name = request.form['dst_column']
        _pattern.description = request.form['desc']
        _pattern.dst_data_type = src_dataElement.getLinkDataType()[0]
        _pattern.dst_data_size = src_dataElement.getLinkDataType()[1]
        _pattern.use_yn = request.form['use_yn']
        _pattern.del_yn = 'N'

        db_session.add(_pattern)
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #10
0
ファイル: manage.py プロジェクト: MiscCoding/gsp_web
def addTypeB():
    existResult = db_session.query(Link_Element_TypeB).filter_by(
        dst_columns_name=request.form['name']).first()
    if (existResult != None):
        raise InvalidUsage('중복된 요소가 존재합니다.', status_code=501)

    try:
        _pattern = Link_Element_TypeB()
        _pattern.dst_columns_name = request.form['name']
        _pattern.description = request.form['desc']

        #operationFuntion 파라메터 생성
        opFunction = list()
        col0 = {
            "type": request.form.get("src_type0"),
            "id": request.form.get("src_column0"),
            "op": request.form.get("src_column_op0")
        }
        opFunction.append(col0)
        #요소 Source가 복수개인 경우
        if request.form.get("colCnt") == "2":
            col1 = {
                "type": request.form.get("src_type1"),
                "id": request.form.get("src_column1"),
                "op": request.form.get("src_column_op1")
            }
            opFunction.append(col1)

        time_range = None

        if request.form.get("tr_op") is not None:
            time_range = {
                "unit": request.form.get("tr_unit"),
                "value": [request.form.get("tr_value0")],
                "op": request.form.get("tr_op")
            }
            if request.form.get("tr_value1") is not None:
                time_range["value"].append(request.form.get("tr_value1"))

        _pattern.setOperateFunction(opFunction, request.form.get("op"),
                                    time_range)

        _pattern.description = request.form['desc']
        _pattern.analysis_cycle = request.form['cycle_value'] + request.form[
            'cycle_opt']
        _pattern.timespan = request.form[
            'timespan_opt'] if request.form['timespan_opt'] != '' else ''
        _pattern.dst_data_type = 'single' if request.form[
            'timespan_opt'] == '' else 'list'
        _pattern.use_yn = request.form['use_yn']
        _pattern.del_yn = 'N'

        db_session.add(_pattern)
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #11
0
def addFileData():
    # jsondata = request.form.get("dna_config");

    # 파일 로드

    file = request.files['file']
    if file.content_type == 'application/vnd.ms-excel':
        try:
            datalist = []
            spamreader = csv.reader(file)

            for index, row in enumerate(spamreader):
                # if index == 0 and isNumberString(row[0]) != True:
                #     continue
                # if isNumberString(row[0]) == True:
                #     datalist.append(row[0])
                # else:
                #     datalist.append(None)

                if int(row[1]) not in [8, 16, 24, 32]:
                    raise InvalidUsage('Mask value is not valid',
                                       status_code=501)

                try:
                    _pattern = Rules_White_IP()
                    _pattern.ip = row[0]
                    _pattern.mask = row[1]
                    _pattern.description = row[2]
                    db_session.add(_pattern)
                    db_session.commit()
                except Exception as e:
                    db_session.rollback()
                    raise InvalidUsage('DB 저장 오류', status_code=501)

        except Exception as e:
            raise InvalidUsage('CSV 로딩 실패, ' + e.message, status_code=501)

        # target link와 데이터 크기 비교
        # target_type = request.form.get("target_type")
        # target_seq = request.form.get("target_seq")
        # if ValidateTargetSize(datalist.__len__(), target_type, target_seq) == False:
        #     raise InvalidUsage('입력 데이터 사이즈가 다릅니다. ', status_code=501)

        # try:
        #     _pattern = Rules_White_IP()
        #     _pattern.ip = request.form['pattern'].strip()
        #     _pattern.mask = request.form['mask'].strip()
        #     _pattern.description = request.form['desc']
        #     db_session.add(_pattern)
        #     db_session.commit()
        # except Exception as e:
        #     db_session.rollback()
        #     raise InvalidUsage('DB 저장 오류', status_code=501)
    else:
        raise InvalidUsage('지원하지 않는 파일 포멧 입니다.', status_code=501)

    return ""
コード例 #12
0
 def addLog(src_ip, important, description):
     log = StandardLog()
     log.id = session['id']
     log.ip = src_ip
     log.importance = important
     log.description = description
     log.cre_dt = datetime.datetime.now()
     db_session.add(log)
     db_session.commit()
     return
コード例 #13
0
ファイル: st_data.py プロジェクト: MiscCoding/gsp_web
def delStData(id):
    try:
        dna = DNA_StandardData.query.filter_by(id=id).first()
        dna.del_yn = 'Y'
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #14
0
def setType_Category_DashboardLinkNP():
    # whitelist = wl_maintenance_period.query.filter_by(datatype='days').first()
    # whitelist.wl_maintenance_period = request.form.get('whitelistvalue')
    try:
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return json.dumps({'success':True}), 200, {'ContentType':'application/json'}
コード例 #15
0
def editwhitelist(seq):
    _pattern = db_session.query(Rules_WhiteList).filter_by(seq=seq).first()
    try:
        _pattern.md5 = request.form['pattern']
        _pattern.description = request.form['desc']
        _pattern.source = request.form['source']
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
コード例 #16
0
 def restoreAccount(self):
     ret_count = Account.query.filter_by(id=self.id).first()
     ret_count.login_fail_cnt = 0
     ret_count.role_id = "001"
     print ret_count.login_fail_cnt
     print ret_count.role_id
     print "executed!"
     try:
         db_session.commit()
     except Exception as e:
         db_session.rollback()
コード例 #17
0
def editRestartSchedule(seq):
    try:
        schedule = db_session.query(DNA_Schedule).filter_by(id=seq).first()
        schedule.restart_request = 1

        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #18
0
def deleteipcollection():
    seqList = request.get_json()
    for alist in seqList['deleteItemList']:
        _pattern = db_session.query(Rules_IP_Collection).filter_by(
            seq=alist).first()
        if _pattern is not None:
            db_session.delete(_pattern)
            db_session.commit()

    return json.dumps({'success': True}), 200, {
        'ContentType': 'application/json'
    }
コード例 #19
0
def editwhiteip(seq):
    _pattern = db_session.query(Rules_White_IP).filter_by(seq=seq).first()
    try:
        _pattern.ip = request.form['pattern'].strip()
        _pattern.mask = request.form['mask'].strip()
        _pattern.description = request.form['desc']

        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
コード例 #20
0
def addIP_Black():
    ip = request.form["ip"]
    desc = request.form["desc"]
    dupCheckResult = db_session.query(IP_BlackList).filter_by(ip=ip).first()
    if dupCheckResult is not None:
        raise InvalidUsage('중복된 IP가 존재 합니다.', status_code=501)
    blackip = IP_BlackList()
    blackip.ip = ip
    blackip.description = desc
    db_session.add(blackip)
    db_session.commit()
    return ""
コード例 #21
0
def editGroup(seq):
    _pattern = db_session.query(Rules_Profile_Group).filter_by(seq=seq).first()
    try:
        _pattern.name = request.form['name']
        _pattern.time_gubun = request.form['time_gubun']
        _pattern.time_value = request.form['time_value']
        _pattern.description = request.form['description']
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
コード例 #22
0
ファイル: manage.py プロジェクト: MiscCoding/gsp_web
def edit_dna(seq):
    #logUtil.addLog(request.remote_addr,1,'links > list ')

    try:
        dna = db_session.query(DNA_Element).filter_by(id=seq).first()
        dna.dna_name = request.form.get("dna_name")
        dna.operate_function = request.form.get("dna_config")
        dna.del_yn = 'N'
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
コード例 #23
0
def setMaxWindowValueSetNP():
    max_window = CommonCode.query.filter_by(
        GroupCode='max_window_value').first()
    max_window.EXT1 = request.form.get('max_window_value')
    try:
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return json.dumps({'success': True}), 200, {
        'ContentType': 'application/json'
    }
コード例 #24
0
def editMalAccount(seq):
    _cnc = db_session.query(malicious_info).filter_by(id=seq).first()
    try:
        #_cnc.rule_type = request.form['type']
        # _cnc.pattern_uri = request.form['pattern_uri']
        # _cnc.description = request.form['desc']
        _cnc.comment = request.form['comment']
        #_cnc.source = request.form['source']
        # _cnc.mod_dt = datetime.datetime.now()
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
コード例 #25
0
ファイル: snort.py プロジェクト: MiscCoding/gsp_web
def editsnortlist(seq):
    _pattern = db_session.query(Rules_Snort).filter_by(seq=seq).first()
    try:
        _pattern.name = request.form['name']
        _pattern.pattern = request.form['pattern']
        _pattern.level = int(request.form['level'])
        _pattern.description = request.form['desc']
        _pattern.mod_dt = datetime.datetime.now()
        _pattern.source = request.form['source']
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
コード例 #26
0
def setDashboardLinkNPNew():
    # uri = CommonCode.query.filter_by(GroupCode='dashboard_linkNP').filter_by(Code='001').first()
    # uri.EXT1 = request.form.get('link')
    divID = request.form.get('div_id')
    iframeElement = TI_Dashboard_data.query.filter_by(div_id=divID).first()
    iframeElement.title = request.form.get('title')
    iframeElement.url = request.form.get('url')
    try:
        db_session.commit()
    except Exception as e:
        raise e.message

    return json.dumps({'success': True}), 200, {
        'ContentType': 'application/json'
    }
コード例 #27
0
def addGroup():

    try:
        _pattern = Rules_Profile_Group()
        _pattern.time_gubun = request.form['time_gubun']
        _pattern.time_value = request.form['time_value']
        _pattern.name = request.form['name']
        _pattern.description = request.form['description']
        db_session.add(_pattern)
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
コード例 #28
0
def deletetitleandurl():
    divID = request.form.get('div_id')
    _pattern = db_session.query(TI_Dashboard_data).filter_by(
        div_id=divID).first()
    _pattern.title = "No Title"
    _pattern.url = ""
    if _pattern is not None:
        try:
            db_session.commit()
        except Exception as e:
            raise e.message

    return json.dumps({'success': True}), 200, {
        'ContentType': 'application/json'
    }
コード例 #29
0
def deletecrawllist():
    deleteID = request.form.get('u_id')
    dataDate = request.form.get('u_datadate')
    # query = Rules_Crawl()

    # elsaticQuery = 'gsp-*'
    # query_type = "url_jobs"
    # cncList = Rules_Crawl.deleteData(elsaticQuery, dataDate, deleteID)
    _pattern = db_session.query(Manual_Crawling_Info).filter_by(
        idx=deleteID).first()
    if _pattern is not None:
        db_session.delete(_pattern)
        db_session.commit()
    # return json.dumps({'success':True}), 200, {'ContentType':'application/json'} ## Initially "" empty string handled statement. I put 200 OK to look clean in the UI
    return ''
コード例 #30
0
def editwhiteip_url(seq):
    _pattern = db_session.query(Rules_White_IP_URL).filter_by(seq=seq).first()
    try:
        _pattern.type = request.form['type'].strip()
        _pattern.ip = request.form['pattern'].strip()
        _pattern.url = request.form['url'].strip()
        _pattern.mask = request.form['mask'].strip()
        _pattern.description = request.form['desc']
        _pattern.mod_dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""