In the hierarchical control paradigm of a smart grid cyber-physical system, decentralized local agents (LAs) can potentially be compromised by opportunistic attackers to manipulate electricity prices for illicit financial gains. In this paper, to address such opportunistic attacks, we propose a Dirichlet-based detection scheme (DDOA), where a Dirichletbased probabilistic model is built to assess the reputation levels of LAs. Initial reputation levels of the LAs are first trained using the proposed model, based on their historical operating observations. An adaptive detection algorithm with reputation incentive mechanism is then employed to detect opportunistic attackers. We demonstrate the utility of our proposed scheme using data collected from the IEEE 39-bus power system with the PowerWorld simulator.Index Terms-Cyber-physical system security, smart grid, opportunistic attack, intrusion detection, smart electricity market, Dirichlet-based reputation.