Coder Social home page Coder Social logo

dicos-public's Introduction

Dicos-public

Dicos is an approach for discovering insecure code snippets in Stack Overflow. Principles and experimental results are discussed in our paper, which will be published at the Annual Computer Security Applications Conference (ACSAC 2021).

※ Exception handling parts may be insufficient due to many modifications in the code refactoring process; we will improve them.

How to use

Requirements

Software

  • Linux: Dicos is designed to work on any of the operating systems. However, currently, this repository only focuses on the Linux environment.

  • Git

  • Python 3

  • Universal-ctags: for function parsing.

  • Joern: for generate code property graph. (only applied in C/C++)

  • cpgqls-client: for communicating with an instance of a Code Property Graph server. (only applied in C/C++)

    • How to install cpgqls-client:
      pip3 install cpgqls-client
      
    • How to setting Joern server:
      • Installation: refer to Joern document
      • After following the installer instructions, by default, joern will be installed at ~/bin/joern.
      • Create a sh file in ~/bin/joern/joern-cli. (filename: joern_running.sh)
        ./joern --server
        

Our utilized versions: Python 3.9.1, and universal-ctags p5.9.20210620.0 on Ubuntu 18.04.

Stack Overflow Dataset

  • Google Bigquery: Dicos requires post information of Stack Overflow. In the paper, Dicos uses SOTorrent dataset (version "2020-12-31") and obtained information using SQL query.

Hardware

  • We recommend 24 GB RAM.

Running Dicos

※ If you have problems related to path information, try testing with absolute paths.

Post Collector

1. Collect StackOverflow raw dataset (src/bigquery_json)

2. Collect code snippets by history (src/PostCodeSnippet_Collector.py)

python3 PostCodeSnippet_Collector.py
  • Check the outputs (description based on the default paths).
    • ./dataset/code_raw/: Directory for storing the latest and the oldest versions of code snippets for each post.

Post Analyzer

1. Pairing code snippets (src/Pairing_CodeSnippet.py)

  • Check the similarity of all code snippets between two versions and diffs in the order of high similarity.
  • Execute Pairing_CodeSnippet.py
python3 Pairing_CodeSnippet.py
  • Check the outputs (description based on the default paths).
    • ./dataset/code_pairs/: Directory for storing two paired code snippets and diff files.

2. Discovering Insecure posts

  • Two ways to analyze the Control-Flow change, one of Dicos detection features.
    • using Regex : See 2-1
    • using Joern-parser : Only applied in C/C++, See 2-2

2-1. Discovering Insecure posts - using Regex (src/Post_Analyzer.py)

python3 Post_Analyzer.py

2-2. Discovering Insecure posts - using Joern Parser (src/Post_Analyzer_usingJoern.py)

python3 Post_Analyzer_usingJoern.py
  • Specify the path regarding Joern to suit the users. (Please change the global variables)

Check the results (description based on the default paths).

  • ./ouput/: Directory for storing results.
  • ./ouput/insecure_posts.txt: List of insecure post IDs. (two or more features detected.)
  • ./ouput/Analyzing_codesnippet.json: Result of the code snippets analysis.
  • ./ouput/Analyzing_keyword.json: Result of the post descriptions and comments analysis.

About

This repository is authored and maintained by Hyunji Hong. For reporting bugs, you can submit an issue to the GitHub repository or send me an email ([email protected]).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.