  Software vulnerabilities (SVs) have become a common, serious, and crucial
concern to safety-critical security systems. That leads to significant progress
in the use of AI-based methods for software vulnerability detection (SVD). In
practice, although AI-based methods have been achieving promising performances
in SVD and other domain applications (e.g., computer vision), they are
well-known to fail in detecting the ground-truth label of input data (referred
to as out-of-distribution, OOD, data) lying far away from the training data
distribution (i.e., in-distribution, ID). This drawback leads to serious issues
where the models fail to indicate when they are likely mistaken. To address
this problem, OOD detectors (i.e., determining whether an input is ID or OOD)
have been applied before feeding the input data to the downstream AI-based
modules. While OOD detection has been widely designed for computer vision and
medical diagnosis applications, automated AI-based techniques for OOD source
code data detection have not yet been well-studied and explored. To this end,
in this paper, we propose an innovative deep learning-based approach addressing
the OOD source code data identification problem. Our method is derived from an
information-theoretic perspective with the use of innovative
cluster-contrastive learning to effectively learn and leverage source code
characteristics, enhancing data representation learning for solving the
problem. The rigorous and comprehensive experiments on real-world source code
datasets show the effectiveness and advancement of our approach compared to
state-of-the-art baselines by a wide margin. In short, on average, our method
achieves a significantly higher performance from around 15.27%, 7.39%, and
4.93% on the FPR, AUROC, and AUPR measures, respectively, in comparison with
the baselines.
