Exemple #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 ""
Exemple #2
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 ""
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 ""
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 ""
Exemple #5
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 ""
Exemple #6
0
def getBlackList():
    blacklist = None
    per_page = int(request.args.get('length'))
    draw = int(request.args.get('draw'))
    start_idx = int(request.args.get('start'))
    search_param = request.args.get('search[value]').strip()

    _codes = None
    if search_param is not u"":
        _codes = IP_BlackList.query.filter(
            IP_BlackList.id.like('%' + search_param + '%'))
    else:
        _codes = db_session.query(IP_BlackList)

    curpage = int(start_idx / per_page) + 1
    blacklist = _codes.order_by(IP_BlackList.id.desc()).paginate(
        curpage, per_page, error_out=False)

    result = dict()
    result["draw"] = str(draw)
    result["recordsTotal"] = str(blacklist.total)
    result["recordsFiltered"] = str(blacklist.total)
    result["data"] = IP_WhiteList.serialize_list(blacklist.items)
    str_json = json.dumps(result)
    return Response(str_json, mimetype='application/json')
Exemple #7
0
def getAccountList():
    accountList = None
    per_page = int(request.args.get('length'))
    draw = int(request.args.get('draw'))
    start_idx = int(request.args.get('start'))
    search_param = request.args.get('search[value]').strip()

    _codes = None
    if session.get("role_id") != "001":
        _codes = Account.query.filter(Account.id == session.get('id'))
    elif search_param is not u"":
        _codes = Account.query.filter(Account.id.like('%' + search_param +
                                                      '%'))
    else:
        _codes = db_session.query(Account)

    curpage = int(start_idx / per_page) + 1
    accountList = _codes.order_by(Account.cre_dt.desc()).paginate(
        curpage, per_page, error_out=False)

    result = dict()
    result["draw"] = str(draw)
    result["recordsTotal"] = str(accountList.total)
    result["recordsFiltered"] = str(accountList.total)
    result["data"] = Account.serialize_list(accountList.items)
    str_json = json.dumps(result)
    return Response(str_json, mimetype='application/json')
Exemple #8
0
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 ""
Exemple #9
0
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 ""
Exemple #10
0
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 ""
Exemple #11
0
def getStandardLogList():
    logList = None
    per_page = int(request.form['perpage'])
    cur_page = int(request.form['curpage'])

    logList = db_session.query(StandardLog)

    _codes = None
    _logs = db_session.query(StandardLog)

    logList = _logs.order_by(StandardLog.seq.desc()).paginate(cur_page, per_page, error_out=False)

    result = dict()
    result["recordsTotal"] = str(logList.total)
    result["recordsFiltered"] = str(logList.total)
    result["data"] = StandardLog.serialize_list(logList.items)
    str_json = json.dumps(result)
    return Response(str_json, mimetype='application/json')
Exemple #12
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 ""
Exemple #13
0
def accountList():
    logUtil.addLog(request.remote_addr, 1, 'system>account')
    ip_allow = db_session.query(GlobalSetting).filter_by(
        key="ALLOW_IP").first()
    ip_allow_value = ip_allow.value

    role_list = CommonCode.query.filter(
        CommonCode.GroupCode == "role_type").all()
    return render_template('system/account.html',
                           ip_allow=ip_allow_value,
                           role_list=role_list)
Exemple #14
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 ""
Exemple #15
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'
    }
Exemple #16
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 ""
Exemple #17
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 ""
Exemple #18
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 ""
Exemple #19
0
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 ""
Exemple #20
0
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 ""
Exemple #21
0
def Customer_List():
    logUtil.addLog(request.remote_addr, 1, 'CUSTOMER > Customer_Management')
    whitelist = wl_maintenance_period.query.filter_by(datatype='days').first()

    query = Integrated_Customer_Category.query
    customerCategory = db_session.query(
        Integrated_Customer_Category.Customer_Category.distinct().label(
            "Customer_Category"))
    customerCategoryList = [
        row.Customer_Category for row in customerCategory.all()
    ]

    return render_template('customerPages/Customer_Management.html',
                           customerCategoryList=customerCategoryList)
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 ""
Exemple #23
0
def editType_Category_url(seq):
    _pattern = db_session.query(Integrated_Type_Category).filter_by(seq=seq).first()
    try:
        _pattern.Field_Name = request.form['Field_Name'].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 ""
Exemple #24
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'
    }
Exemple #25
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 ''
Exemple #26
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 ""
Exemple #27
0
def editipcollection(seq):
    _pattern = db_session.query(Rules_IP_Collection).filter_by(seq=seq).first()
    try:
        _pattern.ip = request.form['pattern'].strip()
        _pattern.mask = request.form['mask'].strip()
        _pattern.etc = request.form['etc'].strip()
        _pattern.detection_point = request.form['detection_point'].strip()
        _pattern.description = request.form['description'].strip()
        _pattern.use_yn = request.form['use_yn'].strip()
        #_pattern.description = request.form['desc']

        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)
    return ""
Exemple #28
0
def editAccount(id):
    _account = db_session.query(Account).filter_by(id=id).first()
    if request.form['password'] != "":
        _account.password = pw = EncryptEncoder.sha256Encrypt(
            request.form["password"])
    _account.cre_dt = datetime.datetime.now()
    _account.email = request.form["email"]
    _account.mobile = request.form["mobile"]
    _account.role_id = request.form["role"]
    _account.culture = request.form["culture"]
    _account.comment = request.form["comment"]
    if request.form["role"] == "001":
        _account.login_fail_cnt = 0

    db_session.commit()
    return ""
Exemple #29
0
def editSchedule(seq):
    try:
        schedule = db_session.query(DNA_Schedule).filter_by(id=seq).first()
        schedule.dna_id = request.form['dna_id']
        schedule.description = request.form['desc']
        schedule.cycle = request.form['cycle_value'] + request.form['cycle_opt']
        schedule.start_time = request.form['start_time']
        schedule.cre_id = session.get('id')
        schedule.filter_ip = request.form['filter_ip']
        schedule.filter_data_type = request.form['filter_data_type']
        db_session.commit()
    except Exception as e:
        db_session.rollback()
        raise InvalidUsage('DB 저장 오류', status_code=501)

    return ""
Exemple #30
0
def addAccount(id):
    dupCheckResult = db_session.query(Account).filter_by(id=id).first()
    if dupCheckResult is not None:
        raise InvalidUsage('중복된 아이디가 있습니다.', status_code=500)
    _account = Account()
    _account.id = id
    _account.password = pw = EncryptEncoder.sha256Encrypt(
        request.form["password"])
    _account.cre_dt = datetime.datetime.now()
    _account.email = request.form["email"]
    _account.mobile = request.form["mobile"]
    _account.role_id = request.form["role"]
    _account.culture = request.form["culture"]
    _account.comment = request.form["comment"]
    db_session.add(_account)
    db_session.commit()
    return ""