The invention provides a code security detection and version control method and
system oriented to a distributed environment, and relates to the technical field of
software security, and the method comprises the following steps: receiving a
source code file submitted by a distributed node, analyzing a
syntax tree structure, extracting semantic features and
control flow features, determining a code calling relationship and a
data access mode, and storing the code calling relationship and the
data access mode; establishing a cross-node code
dependency graph; tracking a calling link and a data flow direction on the
dependency graph, calculating calling frequency, access authority and data
interaction strength among nodes, and identifying a security risk propagation path; constructing a
federated learning network training security
risk identification sub-model, and generating a
security level evaluation result through
encryption gradient aggregation and a
differential privacy protection mechanism; double confirmation is carried out through Hash
verification of a proof-of-
workload layer and threshold
verification of a voting
consensus layer, and version state conversion is constrained based on a
time sequence dependency chain. According to the method, the security risk of the distributed code can be accurately identified, and the secure and controllable management of the version is realized.