There will be no blanket ban on naming undercover officers in a public inquiry into secret police tactics.
Chairman Lord Justice Pitchford is to consider "on a case-by-case basis" 33 applications for secrecy, including from police moles and women who unknowingly had sexual relationships with undercover officers.
He ruled that his starting point would be that no restriction would be made unless it were needed to protect individuals from harm or to safeguard "effective policing".
The level of secrecy is a controversial issue, with the father of murdered teenager Stephen Lawrence saying he will boycott the probe if it is too covert.
Undercover officers gathered information about his family, as well as justice campaigners linked to victims who died at the hands of police, such as Brazilian Jean Charles de Menezes.
In his ruling, Sir Christopher Pitchford said: "The starting point is that no restriction order will be made, in the public interest of openness in the inquiry and its proceedings, unless it is necessary in the countervailing public interest of the protection of individuals from harm and/or effective policing.
"It is not possible to state at the level of principle or generality where the public interest balance will rest. The chairman will approach evaluation on a case-by-case basis according to the nature and quality of evidence received in support of the application."
Scotland Yard has a policy to "neither confirm nor deny" the identity of undercover officers, but Sir Christopher said he will consider "the precise risk of harm or damage its application seeks to avoid or reduce" in each case.
Witnesses who are granted anonymity could give evidence from behind a screen, use a cipher and have their voice disguised.
Neville Lawrence campaigned for a public inquiry into undercover police tactics, and in March urged Sir Christopher to hold "an open and transparent" investigation.
Asked on Tuesday if he would consider boycotting the investigation if it is too secretive, Mr Lawrence told BBC Radio Four's Today programme: "Yes, because we need to get to the truth, and to the bottom of what these people were doing.
"They knew this when they were taking on these jobs, that they had to do the right thing and protect the public as well as themselves, and if they go beyond where they are supposed to have gone then we have to hear and see for ourselves, and they have to give an account for doing something which is wrong.
"You can't get to the truth unless it is open to the public to hear exactly what they did. That is why we have an inquiry, to make sure that they come out in public and divulge exactly what they have been doing, and what they still may be doing."
Mr Lawrence said he would accept some level of secrecy if revealing details would put people in danger.
Home Secretary Theresa May announced the inquiry into undercover policing in England and Wales in 2015 after a series of claims about Scotland Yard's secretive Special Demonstration Squad (SDS), which operated between 1968 and 2008.
One controversial tactic was the use of dead children's identities as cover.
An inquiry hearing is due to take place on June 22 to decide if the Government has a duty to tell bereaved parents that their child's identity was used.