결과 통보 설정
    • PDF

    결과 통보 설정

    • PDF

    Article Summary

    Classic/VPC 환경에서 이용 가능합니다.

    Hash Filter, File Filter의 REST API를 사용하여 검사 결과 통보 설정 코드를 작성하는 방법을 설명합니다.

    참고

    File Filter 개발에 앞서 File Safer 이용 신청, API Gateway 이용 신청 및 API Key 생성을 해야 합니다. 자세한 내용은 File Safer 시작을 참조해 주십시오.

    검사 결과 통보 설정 시나리오

    setNotiConfig API를 사용하여 검사 결과 통보를 설정하는 시나리오는 다음과 같습니다.

    filesafer-programming-noti_scenario_ko

    1. 인증값 생성
    2. 요청 Body 생성
    3. API 요청

    참고

    검사 결과 통보 설정 코드 작성

    시나리오에 따라 코드를 작성해 주십시오. Hash Filter의 setNotiConfig와 File Filter의 setNotiConfig는 요청 URI만 다르고 인증값 및 파라미터 설정은 동일합니다.

    1. 인증값 생성

    네이버 클라우드 플랫폼 API 사용 인증에 필요한 IAM 인증값을 생성해 주십시오. 인증에 필요한 헤더는 다음과 같습니다.

    • x-ncp-iam-access-key: 네이버 클라우드 플랫폼 포털의 마이페이지 > API 인증키 관리 메뉴에서 Access Key 발급
    • x-ncp-apigw-signature-v2 : Access Key와 매핑되는 Secret Key를 HmacSHA256 암호화하여 signature 값 생성(개행 문자는 \n 사용)
    • x-ncp-apigw-api-key : API Gateway를 통해 API Key 발급
    • x-ncp-apigw-timestamp : 인증값은 아니지만 요청 헤더에 포함. API 명세 참고
    참고

    signature 값을 생성하는 방법과 예제 코드는 네이버 클라우드 플랫폼 API 가이드 > API 개요 > 기본 API > Ncloud API > 2.헤더 생성을 참조해 주십시오.

    2. 요청 Body 생성

    setNotiConfig API의 Body에 결과 통보 설정값인 notificationType을 설정해 주십시오. notificationType 설정 값은 다음과 같습니다.

    notificationType설명
    OFF통보하지 않음
    MAL악성 코드 탐지(조회) 시 통보
    MAE악성 코드 탐지 시 또는 조회 실패 시 통보
    ERR조회 실패 시 통보
    ALL모두 통보

    3. API 요청

    Hash Filter setNotiConfig URI 또는 File Filter setNotiConfig URI로 요청을 전송해 주십시오.

    • Hash Filter setNotiConfig URI: https://filesafer.apigw.ntruss.com/hashfilter/v1/setNotiConfig
    • File Filter setNotiConfig URI: https://filesafer.apigw.ntruss.com/filefilter/v1/setNotiConfig

    다음은 Hash Filter setNotiConfig API 요청 예제 코드입니다.

    public void setNotiConfig() throws Exception
    {
    	String ACCESSKEY = "AAAAAAAAAAAAAAAAAAAA"; // access key (from portal or sub account)
        String apikey = API_GATEWAY_KEY;
    	long timestamp = System.currentTimeMillis();
    	String method = "POST";
    	String apiURL = "/hashfilter/v1/setNotiConfig"; 
    
    	String signature = makeSignature(method, apiURL, timestamp);
    
    	URL url = new URL(apiDomain + apiURL);
    	HttpURLConnection con = (HttpURLConnection)url.openConnection();
    	con.setDoOutput(true);
    	con.setRequestMethod(method);
    	con.setRequestProperty("x-ncp-apigw-timestamp", Long.toString(timestamp));
    	con.setRequestProperty("x-ncp-iam-access-key", ACCESSKEY);
    	con.setRequestProperty("x-ncp-apigw-signature-v2", signature);
        con.setRequestProperty("x-ncp-apigw-api-key", apikey);
    	con.setRequestProperty("Content-Type", "application/json");
    	con.setRequestProperty("accept", "application/json");
    
    	// write request body
    	DataOutputStream dos = new DataOutputStream(con.getOutputStream());
    	dos.writeBytes("{\r\n");
    	dos.writeBytes("    \"notificationType\": \"ALL\"\r\n");
    	dos.writeBytes("}");
    
    	// read http response code
    	int responseCode = con.getResponseCode();
    	BufferedReader br = null;
    
    	if(responseCode == 200) {
    		br = new BufferedReader(new InputStreamReader(con.getInputStream()));
    	} else {
    		br = new BufferedReader(new InputStreamReader(con.getErrorStream()));
    	}
    
    	// read http response body
    	String inputLine;
    	StringBuffer response = new StringBuffer();
    	while ((inputLine = br.readLine()) != null) {
    		response.append(inputLine);
    	}
    
    }
    
    참고

    분석 결과를 통보받기 위해 고급 설정 기능을 사용할 수도 있습니다. 고급 설정은 일정 시간 동안 임계치에 해당하는 악성 코드가 탐지되면 통보하는 기능입니다. 해당 API에 대한 자세한 설명은 setThresholdNotiConfig (Hash Filter/File Filter)를 확인해 주십시오.


    이 문서가 도움이 되었습니까?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.